How to fix "npm.ps1 cannot be loaded because running scripts is disabled on this system"

npm.ps1 cannot be loaded because running scripts is disabled on this system? Fix the PowerShell execution policy in 2 steps and run npm commands normally.

Louis avatar
How to fix "npm.ps1 cannot be loaded because running scripts is disabled on this system"

You installed Node.js with the Windows installer, and sucessufully ran node -v in your Terminal. However, when you try to run npm -v, you get the error:

npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.

It doesn’t mean that installation failed. You can try these approaches to check your installation:

  1. Run npm.cmd -v instad of npm -v in your Terminal.

  2. Press Windows key + R, type cmd and press Enter to run a CMD terminal instead of Powershell, and run npm -v in it.

If you successfully get the version number, you have successfully installed Node.js. What you need to do is to enable running scripts in your Powershell.

The fix is simple: open your Terminal (in Powershell environment by default), and run Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.

fix “npm.ps1 cannot be loaded because running scripts is disabled on this system”

This command doesn’t need the Administrator privilege, and it will only affect your current user.

Once it is done, you can run npm -v again in your Terminal, and you should see the version number.

Buy Me a Coffee

Comment

comments powered by Disqus
Louis

Written by : Louis

theWindows12 editor. Windows news, tips, tutorials and guides.

Recommended for You