-bash: yarn: command not found even after installing it globally
Solution 1
If you are using nodenv
and yarn
is not working try a simple
$nodenv rehash
after that yarn should work
Solution 2
try export PATH=~/.yarn/bin:$PATH
into .profile !**
or
try: If you are on the bash try adding alias yarn=~/.yarn/bin/yarn.js
We no longer support global installation of Create React App.
Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app
The latest instructions for creating a new app can be found here:
create-react-app.dev/docs/getting-started
Try this Stackoverflow :)
Solution 3
Global packages won't be installed in a user account. The path you mention is for configuration. Try to find where Yarn was really installed or just try export PATH=/usr/local/bin:$PATH
(that's where Yarn is on my machine).
Related videos on Youtube
vikramvi
Updated on September 15, 2022Comments
-
vikramvi over 1 year
Mac OS 10.13.6
How did I install yarn
npm install --global yarn
yarn installation path is
/Users/useName/.config/yarn
Then ran below command
yarn create react-app app-name
This worked well, but when I'm trying to run
yarn add package_name
, it's throwing errorbash: yarn: command not found
The weird thing, after closing and opening terminal again under which I had globally ( ? ) installed yarn, the yarn command is not found.
-
vikramvi about 3 yearsThis solution didn't work for me, I've edited question and added yarn directory on Mac
-
ullas kunder about 3 yearsDid you tried installing yarn through homebrew package manager
brew install yarn
-
ullas kunder about 3 yearswhat does
yarn --version
says -
ullas kunder about 3 yearsdid you do
yarn init
-
vikramvi about 3 yearsI don't want to install using brew but with npm way. yarn --version just gives error message "command not found"
-
ullas kunder about 3 yearsthat's confirm that yarn is not installed properly
-
vikramvi about 3 yearsstrangely after installing yarn, I could able to run yarn create react-app appName without any failure. How is that possible ? I mean 1st time installation is success and later it didn't work at all ?
-
vikramvi about 3 yearsLet us continue this discussion in chat.
-
vikramvi about 3 yearscan you clarify how did you install yarn & which OS you've ?
-
nydame about 3 yearsSorry, I should have mentioned that I'm using MacOS 10.15.7. I installed yarn with Homebrew.
-
vikramvi about 3 yearsWhich OS are you using ? I'm on Mac and I don't see ~/.profile there.
-
Ti Hausmann about 3 yearsI'm on macOS 11.2.3, I had to create
~/.profile
too