View on GitHub


Node.js virtual environment (sandbox) builder

Download this project as a .zip file Download this project as a tar.gz file


nodeenv (node.js virtual environment) is a tool to create isolated node.js environments.

It creates an environment that has its own installation directories, that doesn't share libraries with other node.js virtual environments.

Also new environment can be integrated with environment which was built by virtualenv (python).


Global installation

You can install nodeenv with easy_install:

$ sudo easy_install nodeenv

or pip:

$ sudo pip install nodeenv

Local installation

If you're using virtualenv then you can install nodeenv via pip/easy_install inside any virtual environment built with virtualenv::

$ virtualenv env
$ . env/bin/activate
(env) $ pip install nodeenv
(env) $ nodeenv --version

If you want to work with the latest version of the nodeenv you can install it from the github repository:

$ git clone
$ ./nodeenv/ --help

Or you can just download raw and use it::

$ wget
$ python --version


Install new environment:

$ nodeenv env

Activate new environment:

$ . env/bin/activate

Chek versions of main packages:

(env) $ node -v

(env) $ npm -v

Deactivate environment:

(env) $ deactivate_node

Saving into the file versions of all installed packages:

$ . env/bin/activate
(env) $ npm install -g express
(env) $ npm install -g jade
(env) $ freeze ../prod-requirements.txt

Create environment copy from requirement file:

$ nodeenv --requirement=../prod-requirements.txt --jobs=4 env-copy

Requirements files are plain text files that contain a list of packages to be installed. These text files allow you to create repeatable installations. Requirements file example:

$ cat ../prod-requirements.txt

If you're already have python virtualenv tool, and want to use nodeenv and virtualenv in conjunction, then you should create (or activate) python virtual environment:

# in case of using virtualenv_wrapper
$ mkvirtualenv my_env

# in cace of using virtualenv
$ . my_env/bin/activate

and add node virtual environment to this existing new_venv:

(my_env) $ nodeenv -p

That's all. Now, all your node.js modules will be installed into your virtual environment:

$ workon my_env
(my_env) $ npm install -g coffee-script
(my_env) $ which coffee