Is there virtualenv for Node.js?

Is there virtualenv for Node.js?

Problem

I am totally new to Node.js. Can anyone tell me if there is anything similar to Python’s virtualenv? I need to run apps on different versions of Node.js on the same machine.

Problem courtesy of: PaolaJ.

Solution

nvm by Tim Caswell

Check out nvm by Tim Caswell, it’s a version manager for Node.js. It allows you to install multiple version of Node.js in parallel, and also manages version-independent variants of the global module cache for you. With nvm it basically comes down to:

$ nvm install 0.10.24
$ nvm use 0.10.24

And then you have Node.js 0.10.24 up and running, including the appropriate version of npm.

Installation of nvm is as easy as running a simple shell command:

$ curl https://raw.github.com/creationix/nvm/master/install.sh | sh

Another option may be n by TJ Holowaychuk or nave by Isaac Z. Schlueter, although I don’t have any experience with either of them.

n by TJ Holowaychuk

Basically, they work quite similar to nvm. Installing n is as easy as running a shell script, too:

$ make install

Afterwards you are able to type:

$ n 0.10.24
$ n

Then you can select which installed version you’d like to use. From what I’ve heard n works better than nvm if you are on Windows.

nave by Isaac Z. Schlueter

nave is a shell script, again, and its usage is similar to that of nvm:

$ nave install 0.10.24
$ nave use 0.10.24

And that’s it :-)!

Solution courtesy of: Golo Roden

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *