yarn : 无法加载文件 C:\Users\Administrator\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。

问题描述:VSCODE终端中使用yarn报错

具体错误信息:

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

解决方案

1. 以管理员模式 打开Windows PowerShell(一般快捷键 win+x 可以唤醒 进行选择)

2. PowerShell输入get-ExecutionPolicy 此时返回 Restricted

3. PowerShell输入set-ExecutionPolicy RemoteSigned

4. PowerShell返回结果 输入Y进行设置

执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y)  [A] 全是(A)  [N] 否(N)  [L] 全否(L)  [S] 暂停(S)  [?] 帮助 (默认值为“N”):

本文来自博客园,作者:Aunrea,转载请注明原文链接:https://www.cnblogs.com/aunrea/p/15740515.html

原文地址:https://www.cnblogs.com/aunrea/p/15740515.html