Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've mentioned that my application uses different version of NodeJS when running from sudo.

$ node -v
v0.10.23
$ sudo node -v
v0.11.8-pre

This v0.11.8-pre caused me some problems, so I definitely don't want to use it, but I can't change it for root.

$ sudo nvm use v0.10.23
sudo: nvm: command not found

I've tried to install nvm from root user, but got error "NVM already installed", but still nvm not found when running from sudo. What is my problem?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
682 views
Welcome To Ask or Share your Answers For Others

1 Answer

The below list of commands (source: digitalocean) seems to fix the problem

WARNING!!!! In some circumstances, these commands can break your system! Make sure you know what do these command do!!! related

n=$(which node); 
n=${n%/bin/node}; 
chmod -R 755 $n/bin/*; 
sudo cp -r $n/{bin,lib,share} /usr/local

The above command is a bit complicated, but all it's doing is copying whatever version of node you have active via nvm into the /usr/local/ directory (where user installed global files should live on a linux VPS) and setting the permissions so that all users can access them.

Hope this helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...