I have an NFS-mounted home folder and am trying to set up global packages via npm, for example:
sudo npm install -g jshint
This gives me an error because under sudo I can't create anything on the remote server (tried this outside of npm)
npm ERR! Error: EACCES, open '/home/explunit/.npm/a02a2468-jshint.lock'
npm ERR! { [Error: EACCES, open '/home/explunit/.npm/a02a2468-jshint.lock']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/home/explunit/.npm/a02a2468-jshint.lock' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
I'm sure somebody will come along in 2 minutes and say "don't use sudo -- a real developer would understand how to set up node/npm without it!", but a) it's never been clear to me how this is designed to work, given that the npm readme suggests sudo, and b) in this case I really don't want anything tied to my specific user (it's a build server)
So I guess the real question is how to make npm ignore my home folder and use some other location for .npm?
On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node. Non-global libraries are installed the node_modules sub folder in the folder you are currently in.
Try to change where the cache is with this.
npm config set cache /SOMEWHERE/ELSE
/SOMEWHERE/ELSE should be somewhere where the user running the command can write.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With