Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Problem: bash: yarn: command not found #601

Closed
micahasmith opened this issue Oct 11, 2016 · 30 comments
Closed

Installation Problem: bash: yarn: command not found #601

micahasmith opened this issue Oct 11, 2016 · 30 comments

Comments

@micahasmith
Copy link

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?

@AntouanK
Copy link

Same here.

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

@moooji
Copy link

moooji commented Oct 11, 2016

Same here:

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

@nickhudkins
Copy link

@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.

@micahasmith
Copy link
Author

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

@moooji
Copy link

moooji commented Oct 11, 2016

@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.

@alfredxing
Copy link

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

@sebmck
Copy link
Contributor

sebmck commented Oct 11, 2016

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 yarnpkg@0.15.1

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!

micahasmith added a commit to micahasmith/yarn that referenced this issue Oct 11, 2016
@syropian
Copy link

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.

@nickhudkins
Copy link

@kittens fixed :) thanks

@minustime
Copy link

Installing via npm worked for me after the last update.

@sillero
Copy link

sillero commented Oct 11, 2016

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

@sebmck
Copy link
Contributor

sebmck commented Oct 11, 2016

@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.

@sebmck
Copy link
Contributor

sebmck commented Oct 11, 2016

@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?

@STCTbone
Copy link

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

@sillero
Copy link

sillero commented Oct 11, 2016

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

@joshmanders
Copy link

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

@leomeloxp
Copy link

@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)

@333Yalindre
Copy link

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

@tzapu
Copy link

tzapu commented Oct 12, 2016

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?

@idkjs
Copy link

idkjs commented Oct 12, 2016

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.

@torifat
Copy link
Member

torifat commented Nov 22, 2016

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

@torifat torifat closed this as completed Nov 22, 2016
@LeJasonGrote
Copy link

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

@chisumo2016
Copy link

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.

@Desboot
Copy link

Desboot commented Dec 7, 2017

You restart bash?

@romenigld
Copy link

romenigld commented Feb 17, 2018

brew install yarn
To have access to Yarn’s 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.

@hieudang59
Copy link

I rosolved, thanks @kittens

@seven-steven
Copy link

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.

@jharvardcodes
Copy link

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 yarnpkg@0.15.1

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!

@nodesocket
Copy link

nodesocket commented Aug 25, 2020

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?

@vikramvi
Copy link

vikramvi commented Mar 16, 2021

On Mac 10.13.6

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.

On Mac 10.13.6 ( npm 6.9.0 ) , I've above entry but still getting error

-bash: yarn: command not found

I've installed yarn with command npm install --global yarn

yarn installation path is /Users/useName/.config/yarn

https://stackoverflow.com/questions/66637032/bash-yarn-command-not-found-even-after-installing-it-globally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests