Home > Mobile >  I installed yarn globally, but got error "zsh:command not found : yarn"
I installed yarn globally, but got error "zsh:command not found : yarn"

Time:10-13

npm install -g yarn

> [email protected] preinstall /Users/myname/.npm-global/lib/node_modules/yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

/Users/myname/.npm-global/bin/yarn -> /Users/myname/.npm-global/lib/node_modules/yarn/bin/yarn.js
    /Users/myname/.npm-global/bin/yarnpkg -> /Users/myname/.npm-global/lib/node_modules/yarn/bin/yarn.js
      [email protected]

As I use a mac, I opened the zshrc file. and then write the code below

export PATH=$PATH:/Users/myname/.npm-global/lib/node_modules/yarn

However, when I entered the yarn --v command, I got the same error as the title.

Could you please tell me what the problem is? What should I do when I have installed a variable globally?

CodePudding user response:

Add the global npm bin to PATH instead:

export PATH="$PATH:$(npm bin -g)"

In your case, this is the same as:

export PATH="$PATH:/Users/myname/.npm-global/bin"
  • Related