How to fix npm ERR! running scripts is disabled on this system. Run Set-ExecutionPolicy to change in npm
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- Open PowerShell as Administrator
- Check your current execution policy
- Change the execution policy to RemoteSigned (Recommended)
- Verify the change and test npm
Get-ExecutionPolicy -Listnpm 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
- 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
- PowerShell version mismatch—different PowerShell versions may have different default policies
- 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"
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.
Run this command to see what policy is currently preventing script execution:
Get-ExecutionPolicy -ListThis 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.
Run this command to enable locally created scripts while maintaining security for downloaded scripts:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSignedYou'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.
Confirm the policy was updated and test that npm now works:
Get-ExecutionPolicy
# Should return: RemoteSigned
npm --version
# Should display npm version without the execution policy error
npm install
# Or whatever npm command was failing beforeIf 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:
# Open Command Prompt and run npm commands
npm install
npm startCommand 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:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSignedCorporate/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
- 📚npm Official Documentation
- 📖Docs: PowerShell execution policies(Official Docs)
- 📖Docs: npmrc configuration(Official Docs)
- 💬SO: PowerShell execution policy(Stack Overflow)