I frequently encounter path related problems while compiling or running an app.I have two versions of node in my system, one is from official repo, the other manually installed from source. Today I wanted to compile brackets, when I run npm install
it asked me to use later version such as 1.4.20. Default version of it is in /usr/bin/npm
which did't work. The manually installed one is in /usr/local/bin/npm
Is there any way to make /usr/local/bin/npm
as default path using update-alternatives
or another method?
For example you can set default text editor with
sudo update-alternatives --config editor
I've found how to do that. At first I checked out default path of
npm
which is older version (1.3.10) in/usr/bin/npm
, I noticed that it's a symbolic link to/usr/share/npm/bin/npm-cli.js
I removed itThen I tried following command
Now I can easily switch between them using
It works well
Since you mentioned node, I thought I might point out that this is a good opportunity to use the N installation manager for NodeJS. If I have a "higher level" package manager like this available, I'll typically use it over update-alternatives. It's generally less complicated than trying to track down important files on your own, IMO. That said, I think update-alternatives will still work.