Installing NVM
Install Node Version Manager (NVM) on your hostingaccount
mkdir -p ~/.nvm
/opt/nvm/install.sh
Uninstall NVM from your hostingaccount
rm -rf ~/.nvm
Using NVM
Show the complete help
nvm --help
Install the latest Node.js version
To install the latest available version of Node.js, you can use the following command:
nvm install node
Next, to use that version of Node.js in any new shell, you can simply run the use command:
nvm use node
Install the latest Node.js LTS version
To install the latest available LTS (Long Term Support) version of Node.js, you can run the following command:
nvm install --lts
And to use that latest LTS version of Node.js in any new shell, you can simply run the use command:
nvm use --lts
More usage examples
Install a specific version number:
nvm install 8.0.0
Use the latest available 8.0.x release:
nvm use 8.0
Run app.js using node 6.10.3:
nvm run 6.10.3 app.js
Run `node app.js` with the PATH pointing to node 4.8.3:
nvm exec 4.8.3 node app.js
Set default node version on a shell:
nvm alias default 8.1.0
Always default to the latest available node version on a shell:
nvm alias default node