Do you want to request a _feature_ or report a _bug_?
feature
What is the current behavior?
Yarn installs to a user's or root's home folder, and links to that folder from /usr/bin.
Since on most Linux only the current user has access to it's home folder, only the user who run the install command can use the globally installed bin utils. For anyone else they get permission denied errors when trying to run the globally installed bin util.
What is the expected behavior?
Global install of bin utils should function like they were installed system-wide, like with apt-get or npm.
Please mention your node.js, yarn and operating system version.
node: 4.6.0, yarn: 0.15.0, OS: Ubuntu 16.04.1
yarn global respects the PREFIX environment variable which overrides the default /usr/bin
You can test the bin resolution with yarn global bin before and after setting the variable.
So the yarn global bin reports /usr/bin for both root and user. That would be all good, and is the same behaviour for npm.
The problem is where those modules are actually staying on the disk.
What npm install --global eslint, does is:
/usr/bin/eslint -> ../lib/node_modules/eslint/bin/eslint.js
While what yarn global add eslint does is:
/usr/bin/eslint -> ../../root/.yarn-cache/.global/node_modules/.bin/eslint
This breaks installation as no user other than root has access to /root/.yarn-cache.
I believe the recommended solution would be to use /usr/lib/node_modules or /usr/lib/yarn_modules or something for global modules.
@hyperknot Is that correct?
I believe the recommended solution would be to use /usr/lib/node_modules or /usr/bin/yarn_modules or something for global modules.
I think you meant /usr/lib/yarn_modules .. Right?
Sorry, of course, edited my post.
I use brew to install node on my macOS.
NPM bin: /usr/local/bin
yarn bin: /usr/local/Cellar/node/6.7.0/bin
I don't know if it could be useful
My attempt to fix it
Seems fixed
Most helpful comment
So the
yarn global binreports/usr/binfor both root and user. That would be all good, and is the same behaviour for npm.The problem is where those modules are actually staying on the disk.
What
npm install --global eslint, does is:While what
yarn global add eslintdoes is:This breaks installation as no user other than root has access to
/root/.yarn-cache.I believe the recommended solution would be to use
/usr/lib/node_modulesor/usr/lib/yarn_modulesor something for global modules.