how to use "update-alternatives" to manage multiple installed version of the same app
Solution 1:
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 it
sudo unlink /usr/bin/npm
Then I tried following command
sudo update-alternatives --install /usr/bin/npm npm /usr/local/bin/npm 10
sudo update-alternatives --install /usr/bin/npm npm /usr/share/npm/bin/npm-cli.js 20
Now I can easily switch between them using
sudo update-alternatives --config npm
It works well
Solution 2:
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.