node.jsinstallationnpm-installyarn-workspacesyarn-v2

Unable to install yarn on windows 10


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

Solution

  • Execute:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted