Friday, June 24, 2016

How to specify a Node version on a project basis

Hi

Today we will learn, how to manage different node version on project basis.
Suppose we have 2 different project which uses different node version. One is using node 5.0 and another is using 6.0. How we manage that.

This is kind of possible with nvm in that if we create a .nvmrc file inside a project and specify a version number, we can cd into the project directory and type nvm use. nvm will then read the contents of the .nvmrc file and use whatever version of Node we specify.

cd into project1 directory.
touch .nvmrc # creates the file
echo \5.0 >> .nvmrc # appends the version to the file

now run command

nvm use 5.0 or nvm use current

it will show

Now using node v5.0.0 (npm v3.3.6)

now cd into project2 directory.
touch .nvmrc # creates the file
echo \6.0 >> .nvmrc # appends the version to the file

now run command

nvm use 6.0 or nvm use current

it will show

Now using node v6.0.0 (npm v3.8.6)

This is how we can manage different version of node for different project.

Thanks

No comments:

Post a Comment