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.
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.
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.
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
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