Can not execute npm package in Powershell?

If you meet error when execute a node.js command(e.g. pm2)

1
2
3
4
5
6
7
8
pm2 : File C:\Program Files\nodejs\pm2.ps1 cannot be loaded. The file C:\Program Files\nodejs\pm2.ps1 is not digitally signed. You cannot run
this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ pm2
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess

Soluation:

Execute the following cmd first, then try again.

1
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

enjoy ;)

Still happen?

Please check Windows Environment variants PATH , make sure npm install path is included.