Yarn: Installation Problem: bash: yarn: command not found

Created on 11 Oct 2016  路  29Comments  路  Source: yarnpkg/yarn

Which operating system are you using:
macOS 10.12

Please describe the steps you took when trying to install Yarn and what went wrong:

I ran curl -o- -L https://yarnpkg.com/install.sh | bash.

My path is as follows, which is strange:

~ echo $PATH
~/.yarn/bin:/ [....]

I feel like there's a missing step with making sure bash/node is setup to respond to .js files on $PATH that have #!/usr/bin/env node, maybe?

Most helpful comment

Thanks for the report! I've just pushed a new version of Yarn to npm and the tarball release should still work. I'm going to leave this open in case anyone is running into anymore issues. To confirm the following install methods that were previously broken should now work:

Tarball

curl -o- -L https://yarnpkg.com/install.sh | bash

npm

$ npm install -g [email protected]

Please keep this issue relevant, if you're still running into issues after following these instructions please comment. Please avoid redundant comments such as "me too" and use GitHub reactions. Thank you everyone!

All 29 comments

Same here.

Just for a test, doing node ~/.yarn/bin/yarn.js works.

Same here:

echo $PATH
~/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

@micahasmith your guess about .js is dead on. yarn.js is accessible. The other option would be to (for now) rename yarn.js -> yarn it has the proper shebang.

@moooji i would expect yarn to be on your $PATH in the first place, though. your issue looks different to mine

@micahasmith I forgot to re-open the terminal. Yarn is now in my path, but I have the same problem: yarn is not found, but yarn.js is.

For now I just added alias yarn="~/.yarn/bin/yarn.js" to my .zshrc (.bashrc if you're on bash)

Thanks for the report! I've just pushed a new version of Yarn to npm and the tarball release should still work. I'm going to leave this open in case anyone is running into anymore issues. To confirm the following install methods that were previously broken should now work:

Tarball

curl -o- -L https://yarnpkg.com/install.sh | bash

npm

$ npm install -g [email protected]

Please keep this issue relevant, if you're still running into issues after following these instructions please comment. Please avoid redundant comments such as "me too" and use GitHub reactions. Thank you everyone!

i had to add export PATH=~/.yarn/bin:$PATH into my .profile to get it working, as the install script only added it to .bashrc which had no effect for me.

@kittens fixed :) thanks

Installing via npm worked for me after the last update.

installed via curl, had to edit .zshrc and remove the double quotes so the ~ would work

@syropian I've added an alert to the tarball installer that we've added something to your shells profile and which one we used so you can do it manually.

@sillero Ah, I'm not a zsh user so wasn't aware. I've changed the installer to use $HOME instead of ~, can you confirm that this is the correct change?

@sillero @kittens Removing the double quotes entirely (leaving export PATH=~/.yarn/bin:$PATH) also works fine

@kittens $HOME works inside double quotes, same as removing the double quotes, both resolve to the home absolute path

Confirmed, replacing ~ in .zshrc with $HOME fixes it.

@joshmanders To expand on this. You can either swap ~ for $HOME or simply remove the double quotes wrapping around the whole definition. Double quotes allow for $VAR like variables to be expanded in zsh/bash but not ~, those are only expanded if not wrapped in any kind of quotes (ie read by terminal directly)

I had the same issue here. after installing via npm its now fine.

in my case i had both a .bashrc (for whatever reason) and a .profile file in $HOME.
the installer script wrote the path to .bashrc and not to .profile. OS X seemed to use .profile.
removed .bashrc, removed .yarn, installed and it wrote to .profile.

maybe it should write the path to all shell configs it finds?

klik:~ klik$ yarn --version
0.15.1
klik:~ klik$ 

Even though I was operating from the User Profile I had to still run export PATH="$HOME/.yarn/bin:$PATH". Yarn then runs. Yarn install added PATH to .bashrc but yarn would not execute from there. I then took it out of .bashrc, opened a new terminal, and yarn still ran.

In case that means anything to you all.

Closing this issues. Feel free to ping back if you are still facing the problem.

i just realized i had to install yarn first by following steps here https://yarnpkg.com/lang/en/docs/install/

I am having a problem has shown below .I am using a window machine
C:\laragon\www\blog-forum>yarn add bulma --dev
'yarn' is not recognized as an internal or external command,
operable program or batch file.

You restart bash?

brew install yarn
To have access to Yarn鈥檚 executables globally, you will need to set up the PATH environment variable in your terminal. To do this, add export PATH="$PATH:yarn global bin"to your profile.

I rosolved, thanks @kittens

i had to add export PATH=~/.yarn/bin:$PATH into my .profile to get it working, as the install script only added it to .bashrc which had no effect for me.

It works for me, Thanks a lot.

Thanks for the report! I've just pushed a new version of Yarn to npm and the tarball release should still work. I'm going to leave this open in case anyone is running into anymore issues. To confirm the following install methods that were previously broken should now work:

Tarball

curl -o- -L https://yarnpkg.com/install.sh | bash

npm

$ npm install -g [email protected]

Please keep this issue relevant, if you're still running into issues after following these instructions please comment. Please avoid redundant comments such as "me too" and use GitHub reactions. Thank you everyone!

STOP READING COMMENTS AND JUST INSTALL THE COMMAND PROVIDED ABOVE. THANK YOU!

i had to add export PATH=~/.yarn/bin:$PATH into my .profile to get it working, as the install script only added it to .bashrc which had no effect for me.

This worked appending the following to .profile:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"

Why does the above NOT work when it's in .bashrc via ssh?

Was this page helpful?
0 / 5 - 0 ratings