windows默认是不允许任何脚本运行的,所以想要使用powershell运行cnpm命令就需要更改powershell的执行权限
powershell脚本的4种执行权限
- Restricted——默认的设置, 不允许任何script运行
- AllSigned——只能运行经过数字证书签名的script
- RemoteSigned——运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名
- Unrestricted——允许所有的script运行
修改powershell执行权限
- 以管理员身份运行powershell
- 然后执行set-ExecutionPolicy RemoteSigned
- 然后输入 A 并且按下回车键,然后就可以使用cnpm命令了。