Yarn is installed but does not work. Command is recognized but no yarn commands do anything. Windows Powershell

Viewed 7159

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.

4 Answers

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

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

For those who are not comfortable with changing Execution policy, here's a solution that worked for me:

Solution: the problem was one extra "\" was missing after bin.

Before: %USERPROFILE%\AppData\Roaming\npm

After: %USERPROFILE%\AppData\Roaming\npm\

Related