我安装了node v16.13.0,npm v8.1.0 java版本1.8.0_211,我以为我也安装了yarn,但试图使用yarn全局添加expo-cli安装expo,我得到:
yarn : File C:Program Filesnodejsyarn.ps1 cannot be loaded. The file C:Program Filesnodejsyarn.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
+ yarn global add expo-cli
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
然后我试图再次安装纱线,但现在我100%无法获得:
PS C:Usersuser> npm install -g yarn
changed 1 package, and audited 2 packages in 1s
found 0 vulnerabilities
但是运行纱线——版本我得到了与以前相同的错误:
yarn : File C:Program Filesnodejsyarn.ps1 cannot be loaded. The file C:Program Filesnodejsyarn.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
+ yarn --version
+ ~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
执行:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
我建议不要更改您的系统策略。
相反,请遵循以下内容:
从目录C:\Users%username%\AppData\Roaming\npm\中删除yarn.ps1,然后尝试清除C:\Users%username%\AppData\Roaming\npm cache\中的npm缓存
在npm安装目录下,将yarn.ps1
重命名为yarn_disabled.ps1
。现在,无论何时调用yarn
,系统都会回退到yarn.CMD
,它不像PowerShell那样具有数字签名的概念。
建议这样做,而不是更改执行策略。