Node.js version
How do I use different Node.js versions at Hipex
In this article we explain how you can adjust the Node.js version per SSH user. The global version of Node.js will not be modified by this action.
Manage Node.js version under your own SSH user
To update the Node.js version, you need to be logged in on the appropriate server using SSH.
Create an empty .bash_profile profile for the SSH user, unless ~/.bash_profile
is already present.
touch ~/.bash_profile
Now that a Bash profile exists, we can install NVM (Node Version Manager) under the user.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
After running the above command, reload the bash_profile:
source ~/.bash_profile
With the command nvm install
you can start a Node.js installation under the SSH user.
For example, if you want to have NodeJS version 12 active, run the following command:
nvm install 12
The installation can take 2 minutes. If the installation went well, you will see Creating default alias: default -> 12 (-> v12.22.6)
You can then easily check if the Node.js version has actually been modified.
node -v
To set this version of node to default, run the next commands.
nvm use <version>
And set it to default:
nvm alias default <version>