How to fix npm ERR! running scripts is disabled on this system. Run Set-ExecutionPolicy to change in npm

npmBEGINNERMEDIUMUpdated Dec 5, 2025· 743 views

This PowerShell error occurs when Windows' execution policy is set to Restricted, preventing npm scripts from running. The fix involves changing the execution policy to RemoteSigned using Set-ExecutionPolicy.

Quick fix

Fixes npm ERR! running scripts is disabled on this system. Run Set-ExecutionPolicy to change

Get-ExecutionPolicy -List
  1. Open PowerShell as Administrator
  2. Check your current execution policy
  3. Change the execution policy to RemoteSigned (Recommended)
  4. Verify the change and test npm
npm — error
Get-ExecutionPolicy -List
npm ERR! running scripts is disabled on this system. Run Set-ExecutionPolicy to change

What this error means

This error occurs when Windows PowerShell's execution policy is set to "Restricted" (the default on Windows 10 and Windows 11), preventing any scripts from running. When npm tries to execute its PowerShell wrapper script (npm.ps1), PowerShell blocks it as a security measure. The error specifically indicates that the npm.ps1 file cannot be loaded because the system policy prohibits script execution. This became common after npm version 6.9.0, when npm began using PowerShell wrapper scripts to enhance the Windows experience. The execution policy is a security boundary designed to prevent accidental execution of malicious scripts, but it also blocks legitimate development tools like npm from functioning properly in PowerShell.

Typical symptoms

  • npm: File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system
  • npm commands fail in PowerShell but work fine in Command Prompt (cmd.exe)
  • npm install, npm start, npm run scripts all fail with this message in PowerShell
  • Error only appears in PowerShell, not in other terminals
  • The error message includes 'Set-ExecutionPolicy to change' as a hint

Common causes

  1. Default Windows PowerShell execution policy is 'Restricted'—Microsoft ships Windows with script execution disabled by default
  2. Recent Node.js installation or update—npm's PowerShell wrapper scripts are blocked on fresh installations
  3. Administrator changed execution policy to 'Restricted'—system administrators may have explicitly locked down policies
  4. PowerShell version mismatch—different PowerShell versions may have different default policies
  5. Domain Group Policy enforcement—corporate environments often enforce strict execution policies via Active Directory

How to fix "npm ERR! running scripts is disabled on this system. Run Set-ExecutionPolicy to change"

1Open PowerShell as Administrator

Launch PowerShell with elevated privileges, which is required to change the execution policy:

1. Click the Windows Start menu
2. Type "PowerShell"
3. Right-click "Windows PowerShell" (not Windows PowerShell ISE)
4. Select "Run as administrator"
5. Confirm the User Account Control prompt if it appears

Verify you're running as administrator by checking for [Admin] in the window title.

2Check your current execution policy

Run this command to see what policy is currently preventing script execution:

powershell
Get-ExecutionPolicy -List

This will display the execution policy at each scope (MachinePolicy, UserPolicy, Process, CurrentUser, LocalMachine). The "CurrentUser" or "LocalMachine" scope showing "Restricted" is what prevents npm from running.

3Change the execution policy to RemoteSigned (Recommended)

Run this command to enable locally created scripts while maintaining security for downloaded scripts:

powershell
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

You'll see a prompt asking to confirm the change. Type Y and press Enter.

The RemoteSigned policy allows scripts written locally (like npm) to run without signatures, while requiring scripts downloaded from the internet to be signed by a trusted publisher.

4Verify the change and test npm

Confirm the policy was updated and test that npm now works:

powershell
Get-ExecutionPolicy
# Should return: RemoteSigned

npm --version
# Should display npm version without the execution policy error

npm install
# Or whatever npm command was failing before
5Alternative: Use Command Prompt instead

If you prefer not to change PowerShell's execution policy, you can simply use the traditional Command Prompt (cmd.exe) instead, which does not have execution policy restrictions:

cmd
# Open Command Prompt and run npm commands
npm install
npm start

Command Prompt does not use PowerShell scripts and will work without any policy changes.

Advanced notes

Execution Policy Levels Explained:
- Restricted (Default): No scripts run, only individual commands execute.
- AllSigned: Only scripts signed by trusted publishers run.
- RemoteSigned (Recommended): Local scripts run freely; scripts from the internet must be signed.
- Unrestricted: All scripts run regardless of origin. Not recommended.
- Bypass: No policy restrictions. Generally unsafe.

Scope Levels:
- CurrentUser: Affects only the current user's PowerShell sessions (safest)
- LocalMachine: Affects all users on the computer (requires administrator)
- Process: Affects only the current PowerShell window (reverts when closed)

Temporary Session-Only Fix: If you want to enable npm just for the current PowerShell session without permanent changes:

powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned

Corporate/Domain-Enforced Policies: If you're on a corporate network and cannot change the execution policy (greyed out in settings), your IT department has enforced a Group Policy. Contact IT support or use Command Prompt instead.

Frequently asked questions

What does "npm ERR! running scripts is disabled on this system. Run Set-Execution" mean?
This error occurs when Windows PowerShell's execution policy is set to "Restricted" (the default on Windows 10 and Windows 11), preventing any scripts from running. ps1), PowerShell blocks it as a security measure. ps1 file cannot be loaded because the system policy prohibits script execution.
How do I fix "npm ERR! running scripts is disabled on this system. Run Set-Execution"?
This PowerShell error occurs when Windows' execution policy is set to Restricted, preventing npm scripts from running. The fix involves changing the execution policy to RemoteSigned using Set-ExecutionPolicy.
What causes "npm ERR! running scripts is disabled on this system. Run Set-Execution"?
Default Windows PowerShell execution policy is 'Restricted'—Microsoft ships Windows with script execution disabled by default Recent Node.js installation or update—npm's PowerShell wrapper scripts are blocked on fresh installations Administrator changed execution policy to 'Restricted'—system administrators may have explicitly locked down policies
Is the "npm ERR! running scripts is disabled on this system. Run Set-Execution" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading