'Yarn is installed but does not work. Command is recognized but no yarn commands do anything. Windows Powershell
node version 11.13.0
npm version 6.9.0
I have installed yarn multiple ways, first with the npm install -g yarn, then I tried the .msi installer, and I also tried installing with chocolatey from an elevated shell. Usually, when I try to use something I have not installed, I get a message that looks like this:
PS C:\Users\[me]> hello
hello : The term 'hello' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ hello
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (hello:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
However, yarn commands are recognized but do nothing.
PS C:\Users\[me]> yarn --version
PS C:\Users\[me]>
I've tried changing the Path environment variable to include the following:
C:\Users\[me]\AppData\Local\Yarn\bin
C:\Program Files (x86)\Yarn
C:\Program Files (x86)\Yarn\bin
but this didn't change anything.
Solution 1:[1]
you must be add %USERPROFILE%\AppData\Roaming\npm in environment path
1-search environment in the start menu https://i.stack.imgur.com/y4zxD.jpg
2-Click environment variables https://i.stack.imgur.com/B59yD.jpg
3-edit path of user variables https://i.stack.imgur.com/Vz73p.jpg
4-add URI of yarn as new https://i.stack.imgur.com/Rq7xK.jpg
then after that if can't use yarn command in vscode and get error yarn.ps1 cannot be loaded because running scripts is disabled on this system; open Powershell as Administrator and run below command
Set-ExecutionPolicy Unrestricted
Solution 2:[2]
--version is not a valid switch, use yarn version instead - https://classic.yarnpkg.com/en/docs/cli/version.
Solution 3:[3]
Even after adding environment variable on windows I got error. Here is fix
%USERPROFILE%\AppData\Roaming\npm in environment path
Open windows command shell as administrator and run command:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | MisterSmith |
| Solution 3 | haldo |
