I need to install yarn without sudo. I do this:
$ npm install -g yarn
and I get this:
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/yarn/bin/yarn.js
npm ERR! dest /usr/bin/yarn
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'
npm ERR! [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'] {
npm ERR! cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/yarn/bin/yarn.js' -> '/usr/bin/yarn'] {
[.........]
But:
ls -al /usr/lib/node_modules/
drwxr-xr-x 5 user1 user1 4096 Sep 15 05:13 .
drwxr-xr-x 63 root root 32768 Sep 14 15:18 ..
drwxr-xr-x 9 user1 user1 4096 Sep 14 14:48 node-gyp
drwxr-xr-x 9 user1 user1 4096 Sep 15 04:22 npm
drwxr-xr-x 7 user1 user1 4096 Sep 14 14:48 semver
And
$ ls -ald /usr/lib/node_modules/
drwxr-xr-x 5 user1 user1 4096 Sep 15 05:13 /usr/lib/node_modules/
Why and how to fix it?
Your config folder must be owned by root, which creates several permissions issue. Changing it to the current user will solve it
$USER:$GROUP -> gives the current login user and the group. in the terminal you can try to echo $USER echo $GROUP to know its value. By this command, it will change to the value present in $USER. The same applies for the group too.
sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config
now try all your commands
replication of https://github.com/bower/bower/issues/2262