DEV Community

Ifeanyi Chima
Ifeanyi Chima

Posted on • Edited on

How to set execution policy for npm start

I bought a new laptop and I need to configure it properly. In this series, I will guide you, so that you can use if for programming.

I got an error when I tried to run npm start

This error was thrown because I had not enabled running of scripts by the computer.

Here is a step-by-step guide to enable running of scripts.

To set the execution policy for npm start in PowerShell, you need to adjust the PowerShell execution policy to allow scripts to run. Here's how:

1. Open PowerShell as Administrator:

Press Win + X and select Windows PowerShell (Admin).

2. Check the Current Execution Policy:

Type the following command and press Enter:

Get-ExecutionPolicy
Enter fullscreen mode Exit fullscreen mode

If the result is Restricted, it means script execution is disabled.

3. Set the Execution Policy:

To allow local scripts to run and require downloaded scripts to be signed, use the following command:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Enter fullscreen mode Exit fullscreen mode

Type Y and press Enter to confirm the change.

4. Verify the New Execution Policy:

Run Get-ExecutionPolicy again to ensure the policy is set to RemoteSigned.

5 Now you should be able to run npm start without encountering the execution policy error.

Top comments (0)