Reputation:
I installed node v16.13.0, npm v8.1.0 java version 1.8.0_211 and I thought I also have installed yarn, but trying to install expo using yarn global add expo-cli I get:
yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded. The file C:\Program Files\nodejs\yarn.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
Then I tried to install yarn again, but now I am 100% unable to get it:
PS C:\Users\user> npm install -g yarn
changed 1 package, and audited 2 packages in 1s
found 0 vulnerabilities
but running yarn --version I get the same error as before:
yarn : File C:\Program Files\nodejs\yarn.ps1 cannot be loaded. The file C:\Program Files\nodejs\yarn.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
Upvotes: 7
Views: 9105
Reputation: 120
Under your npm install directory, rename yarn.ps1
to yarn_disabled.ps1
. Now whenever you call yarn
, the system will fallback to yarn.CMD
which does not have the concept of digital signatures unlike PowerShell.
This is recommended over changing execution policy.
Upvotes: 1
Reputation: 206
I suggest not changing your system policy.
Instead, follow this:
Remove yarn.ps1 from the directory C:\Users%username%\AppData\Roaming\npm\ then try clearing the npm cache at C:\Users%username%\AppData\Roaming\npm-cache\
Upvotes: 6
Reputation: 298
Execute:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Upvotes: 16