Manage Multiple Node Versions

Sep 29, 2016 · 2 min read
Image for post
Image for post

Node.js is a wonderful runtime environment of the decade. When come to managing different versions of Node in same machine for different application will make your life horrible.

Don’t worry, That’s not the end of the story. This article helps on how to overcome and solve this problem with right tools. In short `nvm` and `apn` or `n` and `apn` node module is my proposal to solve this issue.

Installing Node Version Manager

Node Version Manager alias NVM is Node Module which helps to maintain multiple node versions in a same machine to manage various versions.

$ npm install -g nvmor$ npm install -g n

`nvm` and `n` Node Module does not support windows. use below module.

$ npm install -g nvm-windows

Setting Run Time Configuration

The Run Time Configuration alias .nvmrc file which helps to read the version by `avn` Module and you will see below, what is `avn` module about.

$ vi .nvmrc

Installing Automatic Node Version Switching

Automatic Node Version alias AVN is Node Module which helps to switch different version.

AVN provide `avn-nvm` and `avn-n` Module for NVM and N Module compatible from reading your NVM Runtime configuration file (.nvmrc).

$ npm install -g avn avn-nvm avn-n

AVN Updates Bash Profile

AVN Module updates below code in `~/.bash_profile` after its got installed, open this file and make sure its updated and copy this line `~/.profile`.

$ vi ~/.profile[[ -s "$HOME/.avn/bin/" ]] && source "$HOME/.avn/bin/" # load avn

Setting Automatic Node Version

After move to your project directory and create `.nvmrc` file with node version. Set up AVN by using below command. This will update the `~/.avn` File.

$ cd <project_directory>
$ avn setup

Evaluate Bash Profile

Execute the `~/.profile` only once or do it if there any change. File to make AVN commands to be available globally to invoke the command during `cd <directory>`

$ source ~/.profile

You are done!

Yes, you are completed the steps to switch automatically from one version to another and manage different version node projects in same machine.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store