Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sudo user not using same node version

Tags:

linux

node.js

I have a strange issue on my server, when ever i try to install packages with npm that require sudo I run into issues and i have discovered that my su and regular user use different node versions.

$ node -v i get node version  0.10.x

But when i do:

$ sudo node -v i get node version 0.6.x

My su user for some reason is using a different node version than what i normally use and this causes compatibility issues when I npm install packages that require sudo.

I have tried sudo apt-get upgrade nodejs at no luck. how do i make su user use same node version as my regular user.

like image 487
Alon Carmel Avatar asked Oct 02 '14 06:10

Alon Carmel


People also ask

Can you have multiple Nodejs versions?

Multiple Node JS Versions with NVM. NVM (Node Version Manager) can also be used to manage multiple NodeJS versions at the same time. You can install setup NVM in your machine by running the following commands.

How do I switch between node versions?

Node Version Manager (NVM) is a great tool and easy to switch between multiple node versions while working on projects that required different NodeJs versions. It saves a lot of development time by just switching to the version of nodejs needed.


1 Answers

run ll /usr/bin/node if this file exist, simply run rm /usr/local/bin/node from the regular user

explanation

If you'd run which node from regular user you will probably see it points to the user local bin directory

which node
/usr/local/bin/node

this means that the regular user installed another node version locally.

to let the same node version apply to all users, this command should show you usr bin (not local).

which node 
/usr/bin/node

by deleting the link from /usr/local/bin/node it will automatically start using /usr/bin/node

like image 80
guy mograbi Avatar answered Sep 22 '22 05:09

guy mograbi