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.
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.
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.
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.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error