Yarn: global binaries don't install on mac os sierra

Created on 21 Oct 2016  Β·  37Comments  Β·  Source: yarnpkg/yarn

Do you want to request a _feature_ or report a _bug_?
bug

What is the current behavior?
installing global packages does not appear to work.

If the current behavior is a bug, please provide the steps to reproduce.

Β» yarn global add cleanup-dependencies html-validator-cli jspm node-inspector bower css-lint grunt grunt-cli gulp html-validator-cli mjml nativefier node-sass nodemon svg-sprite svgo tldr wring pubstorm pug-lint npm-check-updates
yarn global v0.16.0
warning No license field
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Installed [email protected] with binaries:
      - clean-deps
success Installed [email protected] with binaries:
      - html-validator
success Installed [email protected] with binaries:
      - jspm
success Installed [email protected] with binaries:
      - node-inspector
      - node-debug
success Installed [email protected] with binaries:
      - bower
success Installed [email protected] with binaries:
      - sass-lint
success Installed [email protected] with binaries:
      - grunt
success Installed [email protected] with binaries:
      - grunt
success Installed [email protected] with binaries:
      - gulp
success Installed [email protected] with binaries:
      - html-validator
success Installed [email protected] with binaries:
      - mjml
success Installed [email protected] with binaries:
      - nativefier
success Installed [email protected] with binaries:
      - node-sass
success Installed [email protected] with binaries:
      - nodemon
success Installed [email protected] with binaries:
      - svg-sprite
success Installed [email protected] with binaries:
      - svgo
success Installed [email protected] with binaries:
      - tldr
success Installed [email protected] with binaries:
      - wring
success Installed [email protected] with binaries:
      - storm
success Installed [email protected] with binaries:
      - pug-lint
success Installed [email protected] with binaries:
      - npm-check-updates
      - ncu
✨  Done in 13.38s.
Β» yarn bin
/Users/ds/node_modules/.bin

Β» ls -la ~/node_modules
ls: /Users/ds/node_modules: No such file or directory
Β» yarn global ls
yarn global v0.16.0
warning No license field
info [email protected] has binaries:
   - bower
info [email protected] has binaries:
   - clean-deps
info [email protected] has binaries:
   - sass-lint
info [email protected] has binaries:
   - grunt
info [email protected] has binaries:
   - grunt
info [email protected] has binaries:
   - gulp
info [email protected] has binaries:
   - html-validator
info [email protected] has binaries:
   - jspm
info [email protected] has binaries:
   - mjml
info [email protected] has binaries:
   - nativefier
info [email protected] has binaries:
   - node-inspector
   - node-debug
info [email protected] has binaries:
   - node-sass
info [email protected] has binaries:
   - nodemon
info [email protected] has binaries:
   - npm-check-updates
   - ncu
info [email protected] has binaries:
   - storm
info [email protected] has binaries:
   - pug-lint
info [email protected] has binaries:
   - svg-sprite
info [email protected] has binaries:
   - svgo
info [email protected] has binaries:
   - tldr
info [email protected] has binaries:
   - wring
✨  Done in 8.32s.
ds at selfagency-macpro in ~
Β» bower
fish: Unknown command 'bower'
ds at selfagency-macpro in ~
Β» gulp
fish: Unknown command 'gulp'
ds at selfagency-macpro in ~
Β» grunt
fish: Unknown command 'grunt'

What is the expected behavior?
the binaries should be executable.

Please mention your node.js, yarn and operating system version.

Β» node -v
v6.8.1

Β» yarn --version
0.16.0

Β» sw_vers -productVersion
10.12.1
triaged

Most helpful comment

I had similar issues - I fixed them with export PATH="$PATH:$(yarn global bin)"

All 37 comments

same problem. 0.16.x is buggy

Same here:

➜  ~ yarn global ls
yarn global v0.16.0
warning No license field
info [email protected] has binaries:
   - cat-names
✨  Done in 0.90s.
➜  ~ cat-names
zsh: command not found: cat-names

But my bin folder is somewhere else:

➜  ~ yarn global bin
/usr/local/Cellar/node/6.9.1/bin

That looks really strange. I've installed Yarn via brew. Also the installation guide says, the bin should be actually $HOME/.yarn/bin.

Btw, why doesn't Yarn use /usr/local/bin like npm?

I got global bins working by altering my path from what the docs say in the alternative installation section from export PATH="$PATH:$HOME/.yarn/bin" to export PATH="$PATH:$HOME/.yarn/bin:$HOME/.yarn-config/global/node_modules/.bin".

I use nvm with yarn installed through npm as a global package.

I had similar issues - I fixed them with export PATH="$PATH:$(yarn global bin)"

Packages are not installed under $HOME/.yarn/bin folder. This breaks the instructions given in the documentation

$ yarn global bin
/usr/local/Cellar/node/7.0.0/bin

Same issue here (Mac OS X Yosemite 10.10.5, Node 7.1.0, , Yarn 0.16.1 installed via brew):

$ yarn global bin
/usr/local/Cellar/node/7.1.0/bin

This is a _also_ a problem because the path is specific to the version of node used to install globally

I encountered this trouble on another platform (Ubuntu), in which yarn global ad did not set things up correctly on the path. I see above that @teehemkay installed via brew. I encountered the problem what I had installed yarn using NPM, which is listed as one of the acceptable ways to install it in the documentation. When I installed using its curl-bash installer (wincing at the security, and working in an isolated testing environment), the problem evaporated and global paths worked the first time. It is possible that the problem in this issue is another variation, I would not find this surprising at all because there are so many different ways to install both yarn and node.

Same problem here, it's very anoying :

  ~
 ➜  sw_vers
ProductName:    Mac OS X
ProductVersion: 10.12.1
BuildVersion:   16B2555

  ~
 ➜  brew install node yarn
Warning: node-7.1.0 already installed
Warning: yarn-0.17.2 already installed

  ~
 ➜  yarn global bin
/usr/local/Cellar/node/7.1.0/bin

  ~
 ➜  yarn global ls
yarn global v0.17.2
✨  Done in 0.05s.

  ~
 ➜  yarn global add yarn-completions
yarn global v0.17.2
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ“ƒ  Building fresh packages...
success Installed [email protected] with binaries:
      - completions-yarn
✨  Done in 7.75s.

  ~
 ➜  yarn global ls
yarn global v0.17.2
warning No license field
info [email protected] has binaries:
   - completions-yarn
✨  Done in 1.08s.

  ~
 ➜  completions-yarn
zsh: command not found: completions-yarn

  ~
 ➜  ls $(yarn global bin)
node

  ~
 ➜  ls ~/.yarn/bin/
ls: /Users/david/.yarn/bin/: No such file or directory

  ~
 ➜  find ~ -name yarn-completions
/Users/david/.config/yarn/global/node_modules/yarn-completions

so i can't add "_/Users/david/.config/yarn/global/node_modules/_" to my $PATH, cause the problem is this directory is a complete trash with all node modules dependancies.

I solved installing [email protected] (the same version coming from the bash installer) via npm global.
Everything works now with the node 7.1.0 installed via nvm and [email protected].
With the latest 0.17.2 the global install doesn't work for me.

@gekorob thanks for the tips

mac osx sierra
[email protected] installed via nvm
[email protected] installed via npm -g

I'm facing the same problem with "global add" like in the 0.17.2 (e.g. yarn global add angular-cli doesn't install ng command).
Downgrading to [email protected] everything works again

Ok solved applying the correct path to my ~/.bash_profile as written in yarn documentation.
I apologise for the previous comment but now everything works with the [email protected]

I have similar issues on Ubuntu and Mac OS.

Yarn was installed through apt-get on Ubuntu and Homebrew in Mac OS, and I am using nodenv in both OSs.

yarn global bin returns $HOME/.nodenv/versions/7.2.1/bin which only contains node and npm.

But the binaries are actually in $HOME/.config/yarn/global/node_modules/.bin.

The solutions here do not seem to fix the problem, except for adding $HOME/.config/yarn/global/node_modules/.bin to the PATH which seems rather hackish.

Any suggestions?

same here

this works for me as of v0.19.1

not work for me
Is global modules really install in yarn global bin? I enter and only node in there

$ cd $(yarn global bin) && ls -a
.    ..   node

It wasn't working for me when using NVM because I had accidentally removed NVM_DIR from my bash_profile.

adding this:

export NVM_DIR="$HOME/.nvm"
  . "/usr/local/opt/nvm/nvm.sh"

to ~/.bash_profile fixed my problem

FYI, I had to add yarn global bin to PATH before I added NVM via Homebrew. Works great for me, yarn added through homebrew on Mac.

https://github.com/yarnpkg/yarn/issues/630#issuecomment-277837483 worked for me as of Yarn 0.21.3 on Mac OS X 10.11.6. After I set the prefix, I removed and re-added packages and global access worked from then on (remember to re-open any terminal windows that might have your old PATH):

yarn config set prefix /usr/local/
yarn global remove <package>
yarn global add <package>

Can list installed packages with:

yarn global ls

Hello. I use fish shell with OMF on macOS and solved this problem by adding to my ~/.config/fish/config.fish file
set -x PATH $PATH $HOME"/.config/yarn/global/node_modules/.bin"

I have similar problems on KDE Neon (Ubuntu 16.04.2). But I think I see what's going on.
npm install -g is actually using as an install target directory what yarn global bin _says_ it's using, but yarn is lying.

From the comment above by @curtdp I realized that yarn global add installs symlinks for module binaries in $HOME/.config/yarn/global/node_modules/.bin. When I install a package using a command like yarn global add bower it creates symlink $HOME/.config/yarn/global/node_modules/bin/bower.

But yarn global bin gives

/home/alan/.nvm/versions/node/v7.7.1/bin

This is a bug. Of course, we can all work around it by adding the directory path $HOME/.config/yarn/global/node_modules/bin to our shell's PATH, but really Yarn should be saying what it's doing and doing what it says with the yarn global bin command.

/usr/local/share/.config/yarn/global/package.json:
{ "dependencies": { "@angular/cli": "^1.0.0-beta.30" } }

But $ sudo yarn global ls:
yarn global v0.22.0 Done in 0.18s.

i use this commond
yarn config set prefix "D:\Program Files (x86)\Yarn\node-global"
and add "D:\Program Files (x86)\Yarn\node-global" to PATH.
then
'yarn global add express-generator'
it add supervisor.cmd this file in "D:\Program Files (x86)\Yarn\node-global",
but when i use
express -V
An error occurred that means the file name, directory name, or volume label syntax is incorrect.

@jay763190097 this issue is about OSX not Windows.

@bestander we can close this because it is a duplicated.

npm install -g is helpful this case :)

i know this is closed but in case others stumble, i saw a package just for this issue. $ npm install -g fix-yarn-global-packages

then just run it to relink packages. refer to: https://www.npmjs.com/package/fix-yarn-global-packages

yarn global bin

/usr/bin

But exactly binary file is here.

/usr/local/share/.config/yarn/global/node_modules/.bin/

I have two users on my MacOS. When I added this to path:

export PATH="$PATH:$(yarn global bin)"

I get error: zsh: permission denied: apidoc. Any ideas why?

I'm facing the same problem on KDE Neon (Ubuntu 16.04.2). Yarn version 0.27.5
yarn global bin returns /home/aislan/.asdf/installs/nodejs/7.2.1/.npm/bin

Having installed yarn through npm, to solving the problem just follow up the Yarn's guide that says:
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.

Since I'm using zsh, I put PATH command in .zshrc file.

"globalFolder": "/Users/c01nd01r/.config/yarn/global",
but yarn global bin
/usr/local/bin πŸ€”

@c01nd01r I have a similar situation.

Still the same here.

"globalFolder": "/Users/c01nd01r/.config/yarn/global",
but yarn global bin
/usr/local/bin πŸ€”

  • Your global directory is ~/.config/yarn/global (this is where yarn global add stores modules)
  • Your Yarn binary location is /usr/local/bin (I'm assuming you installed via homebrew?)

If you're having issues like I did earlier, I changed into ~/.config/yarn/global and removed package.lock(if any) and yarn.lock and tried a yarn global create-react-app install globally and it went back to normal.

I had the following:

$ yarn global bin
/usr/local/bin

$ yarn global dir
/Users/<me>/.config/yarn/global

Even yarn global remove <package> and re-adding didn't work, but the global directory did have the binary, so I knew there was a problem with the $PATH.

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

Didn't work: export PATH="$(yarn global bin):$PATH"

Then just source ~/.bashrc (or wherever your bash settings are), and yarn global add <package> even though it already exists. That was the only thing that removed the error.

Yarn was installed via apt on Ubuntu, I have to add this to .zshrc,

' not work: export PATH="$HOME/.config/yarn/global/node_modules/bin:$PATH"
export PATH="$(yarn global bin):$PATH"
Was this page helpful?
0 / 5 - 0 ratings