Setting up Javascript environment with NVM on Ubuntu 14.04

NVM provides you more convenient way to manage and set up your Javascript(Node.js) environment.

First install NVM, note git must be installed on your sistem:
^
git clone https://github.com/creationix/nvm.git ~/.nvm && cd ~/.nvm && git checkout git describe --abbrev=0 --tags
^
To activate nvm, you need to source it from your shell:
^
cd # go to home folder
^
source ~/.nvm/nvm.sh
^
If you want to see what versions of Node.js are available to install:
^
nvm ls-remote
^
To install Node.js v0.11.14 just run:
^
nvm install 0.11.14
^
And then in any new shell just use the installed version:
^
nvm use 0.11.14
^
Now check Node.js version:
^
node -v # you should see: v0.11.14
^
Now you can use this version of Node.js as default on your system. To set a default Node version to be used in any new shell, use the alias default:
^
nvm alias default 0.11.14
^
But if in different projects you're using different Node.js versions, then you must, any time you go to the project folder, select proper Node.js version with nvm use <version> command, or you can create in project root folder .nvmrc file, with content:
^
v0.11.14
^
And after that you just need to run nvm use and nvm get version from this file. nvm use, nvm install, nvm exec, and nvm run will all respect an .nvmrc file.

konjoot Over 9 years ago