Reputation: 1018
How can I install NodeJS, not at the OS level, but without sudo privileges inside my home dir?
The thing is, I need to test my library with [at least] three versions of NodeJS:
I wanted to install them in separate directories such as:
~/apps/nodejs-10
~/apps/nodejs-12
~/apps/nodejs-14
And then just use a symlink to switch between them if I need to (for example for version 12):
$ ls -s ~/apps/nodejs-12 ~/apps/nodejs_home
How do I do this?
Upvotes: 3
Views: 2144
Reputation: 1018
I was finally able to perform the non-root installation. To do this I downloaded the NodeJS packages from https://nodejs.org/download/release. Specifically:
Then, it's a matter of decompress them:
$ mdkir apps && cd apps
$ tar -xJf node-v10.9.0-linux-x64.tar.xz
$ tar -xJf node-v12.16.3-linux-x64.tar.xz
$ tar -xJf node-v14.2.0-linux-x64.tar.xz
$ ln -s node-v12.16.3-linux-x64 node
And finally adding it to the PATH, as in:
$ export NODE_HOME=~/apps/node
$ export PATH=$NODE_HOME/bin:$PATH
To check, I ran:
$ node --version
v12.16.3
To switch to a different version, it's easy as to change the symlink (without touching your environment or PATH). For version 10:
$ rm apps/node && ln -s node-v10.19.0-linux-x64 apps/node
$ node --version
v10.19.0
or for version 14:
$ rm apps/node && ln -s node-v14.2.0-linux-x64 apps/node
$ node --version
v14.2.0
Easy peasy.
Upvotes: 4