top

powershell显示xxx: 无法加载文件 xxxx,因为在此系统上禁止运行脚本...

安装nodejs后,执行npm命令,显示

npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 https:/go.microsof
t.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 1
+ npm install -g yarn
+ ~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

解决方法

  1. 在终端输入get-ExecutionPolicy查看执行策略/权限;
  2. 输出Restricted(受限制的);
  3. 终端输入Set-ExecutionPolicy -Scope CurrentUser命令给用户赋予权限;
  4. 输入RemoteSigned
  5. 终端输入get-ExecutionPolicy查看一下权限,显示RemoteSigned就可以了。

THE END
icon
0
icon
打赏
icon
分享
icon
二维码
icon
海报