This just follows Option 2 in this tutorial: https://docs.npmjs.com/getting-started/fixing-npm-permissions
The only difference is not using ~
because I read somewhere something chokes on it sometimes. So $HOME
.
mkdir ~/.npm-global
npm config set prefix $HOME/.npm-global
in ~/.bashrc:
export PATH="$HOME/.npm-global/bin:$PATH"
This was done in a rage of frustration where I ended up wiping out all node/npm existence before finding something that works, so I have no idea if just following this will work on a machine that already has stuff installed via npm/yarn. If it does, please let me know.
Does it really work with yarn too?