Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fix for npm global install on Ubuntu

I have a nodejs package that requires a global install. This one fails in a way that leads me to believe there might be a configuration problem in the the Ubuntu package npm. This happens every-time I setup an Ubuntu 14.04 machine.

sudo apt-get install npm
npm install -g lineman

The npm -g command will throw some access error naming the local lib and bin directories. Unlike some global installs, it is not an option to cheat and run the second command under sudo. So, the only fix I have found that will work is something like this:

sudo chgrp -R $(whoami) /usr/local/bin /usr/local/lib
sudo chmod -R g+rwx /usr/local/bin /usr/local/lib

The fix is fine for me, I'm the only user. But is this really the best way to do it? I don't want to document my fix for anyone else that might use it in an environment where this will not work or cause trouble.

Also, should I file a bug report with someone who packages npm for Ubuntu?

like image 759
jcalfee314 Avatar asked Dec 10 '25 05:12

jcalfee314


1 Answers

Using sudo is unsafe and completely is NOT recommended option to fix such error.

As Jay Jodiwal offered in the comment, the ONLY correct way to fix this error is using the official documentation on how to run npm without sudo.

https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

like image 106
redCuckoo Avatar answered Dec 11 '25 22:12

redCuckoo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!