-bash: yarn: command not found even after installing it globally

11,437

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

@github ;)

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

Share:
11,437

Related videos on Youtube

vikramvi
Author by

vikramvi

Updated on September 15, 2022

Comments

  • vikramvi
    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 error

    bash: 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
    vikramvi about 3 years
    This solution didn't work for me, I've edited question and added yarn directory on Mac
  • ullas kunder
    ullas kunder about 3 years
    Did you tried installing yarn through homebrew package manager brew install yarn
  • ullas kunder
    ullas kunder about 3 years
    what does yarn --version says
  • ullas kunder
    ullas kunder about 3 years
    did you do yarn init
  • vikramvi
    vikramvi about 3 years
    I don't want to install using brew but with npm way. yarn --version just gives error message "command not found"
  • ullas kunder
    ullas kunder about 3 years
    that's confirm that yarn is not installed properly
  • vikramvi
    vikramvi about 3 years
    strangely 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
    vikramvi about 3 years
  • vikramvi
    vikramvi about 3 years
    can you clarify how did you install yarn & which OS you've ?
  • nydame
    nydame about 3 years
    Sorry, I should have mentioned that I'm using MacOS 10.15.7. I installed yarn with Homebrew.
  • vikramvi
    vikramvi about 3 years
    Which OS are you using ? I'm on Mac and I don't see ~/.profile there.
  • Ti Hausmann
    Ti Hausmann about 3 years
    I'm on macOS 11.2.3, I had to create ~/.profile too