skip to navigation
skip to content

Not Logged In

nodeenv 0.13.1

Node.js virtual environment builder

Node.js virtual environment

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 the new environment can be integrated with the environment which was built by virtualenv (python).

If you use nodeenv feel free to add your project on wiki: Who-Uses-Nodeenv.

Install

Global installation

You can install nodeenv globally with easy_install:

$ sudo easy_install nodeenv

or with pip:

$ sudo pip install nodeenv

or on Debian using dpkg:

$ ln -s debian-upstream debian
$ dpkg-buildpackage -uc -us -b
$ sudo dpkg -i $(ls -1rt ../nodeenv_*.deb | tail -n1)

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
0.6.5

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

$ git clone https://github.com/ekalinin/nodeenv.git
$ ./nodeenv/nodeenv.py --help

or with pip:

$ pip install -e git+https://github.com/ekalinin/nodeenv.git#egg=nodeenv

Dependency

For nodeenv

  • python (>= 2.6)
  • make
  • tail

For node.js

  • libssl-dev

Usage

Basic

Create new environment:

$ nodeenv env

Activate new environment:

$ . env/bin/activate

Check versions of main packages:

(env) $ node -v
v0.10.26

(env) $ npm -v
1.4.3

Deactivate environment:

(env) $ deactivate_node

Advanced

Get available node.js versions:

$ nodeenv --list
0.0.1   0.0.2   0.0.3   0.0.4   0.0.5   0.0.6   0.1.0
0.1.2   0.1.3   0.1.4   0.1.5   0.1.6   0.1.7   0.1.8
0.1.10  0.1.11  0.1.12  0.1.13  0.1.14  0.1.15  0.1.16
0.1.18  0.1.19  0.1.20  0.1.21  0.1.22  0.1.23  0.1.24
0.1.26  0.1.27  0.1.28  0.1.29  0.1.30  0.1.31  0.1.32
0.1.90  0.1.91  0.1.92  0.1.93  0.1.94  0.1.95  0.1.96
0.1.98  0.1.99  0.1.100 0.1.101 0.1.102 0.1.103 0.1.104
0.2.1   0.2.2   0.2.3   0.2.4   0.2.5   0.2.6   0.3.0
0.3.2   0.3.3   0.3.4   0.3.5   0.3.6   0.3.7   0.3.8
0.4.1   0.4.2   0.4.3   0.4.4   0.4.5   0.4.6

Install node.js “0.4.3” without ssl support with 4 parallel commands for compilation and npm.js “0.3.17”:

$ nodeenv --without-ssl --node=0.4.3 --npm=0.3.17 --jobs=4 env-4.3

Install node.js from prebuilt package:

$ nodeenv --node=0.10.25 --prebuilt env-0.10.25-prebuilt

It’s much faster than installing & compiling node.js from source:

$ time nodeenv --node=0.10.25 --prebuilt env-0.10.25-prebuilt
 + Install node.js (0.10.25) ... done.

real    0m6.928s
user    0m0.408s
sys     0m1.144s

$ time nodeenv --node=0.10.25 env-0.10.25-src
 + Install node.js (0.10.25) ... done.

real    4m12.602s
user    6m34.112s
sys     0m30.524s

Create a new environment with the system-wide node.js:

$ nodeenv --node=system

Saving the versions of all installed packages to a file:

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

If you want to list locally installed packages use -l option:

(env-4.3)$ freeze -l ../prod-requirements.txt

Create an environment from a requirements file:

$ nodeenv --requirements=../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
connect@1.3.0
express@2.2.2
jade@0.10.4
mime@1.2.1
npm@0.3.17
qs@0.0.7

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

# in case of using virtualenv_wrapper
$ mkvirtualenv my_env

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

and add a node virtual environment to this existing new_venv:

$ nodeenv -p

If you need to set the path to make used to build node:

$ nodeenv -m /usr/local/bin/gmake ENV

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

$ workon my_env
$ npm install -g coffee-script
$ which coffee
/home/monty/virtualenvs/my_env/bin/coffee

If environment’s directory already exists then you can use --force option:

$ nodeenv --requirements=requirements.txt --jobs=4 --force env

If you already have an environment and want to update packages from requirements file you can use --update option:

$ . env-4.3/bin/activate
(env-4.3)$ nodeenv --requirements=requirements.txt --update env-4.3

If you want to call node from environment without activation then you should use shim script:

$ ./env-4.3/bin/shim --version
v0.4.3

If you want to install iojs instead of nodejs then use --iojs:

$ virtualenv env
$ . env/bin/activate
(env) $ nodeenv --iojs --list
1.0.0   1.0.1
(env) $ nodeenv --iojs -p --prebuilt
 * Install iojs (1.0.1) ... done.
 * Appending data to ~/tmp/env/bin/activate

Configuration

You can use the INI-style file ~/.nodeenvrc to set default values for many options, the keys in that file are the long command-line option names.

These are the available options and their defaults:

[nodeenv]
debug = False
jobs = 2
make = make
node = latest
npm = latest
prebuilt = False
profile = False
with_npm = False
without_ssl = False

Alternatives

There are several alternatives that create isolated environments:

  • nave - Virtual Environments for Node. Nave stores all environments in one directory ~/.nave. Can create per node version environments using nave use envname versionname. Can not pass additional arguments into configure (for example –without-ssl) Can’t run on windows because it relies on bash.
  • nvm - Node Version Manager. It is necessarily to do nvm sync for caching available node.js version. Can not pass additional arguments into configure (for example –without-ssl)
  • virtualenv — Virtual Python Environment builder. For python only.

LICENSE

BSD / LICENSE

Nodeenv changelog

Version 0.13.1

  • Fixed bug: nodeenv --list is raising TypeError. See # 117, # 118

Version 0.13.0

  • Removed deps from sort, egrep, curl, tar. See # 114, # 116.

Version 0.12.3

  • Fixed check for installed curl/tar/etc for py3.

Version 0.12.2

  • Added check for installed curl/egrep/sort/tar. See # 110, # 61

Version 0.12.1

  • Removed dep for lxml in favor of stdlib HTMLParser. See # 109
  • Added integration with travis-ci. See # 109
  • Added some tests. See # 109

Version 0.12.0

  • Added support for io.js (new option --iojs)
  • Fixed get_last_stable_node_version for python3

Version 0.11.1

Version 0.11.0

  • Improved dpkg rules. See # 90
  • Added –config-file option. See # 91
  • Read “./setup.cfg” in addition to “~/.nodeenvrc” by default. See # 91
  • Python3 compatibility. See # 92, # 93

Version 0.10.0

  • Added support for config file. See # 85
  • Using of virtualenv detected via python not env variable. See # 87
  • Fixed freeze for zsh. See # 88
  • Added nodejs symlink creation. See # 84

Version 0.9.6

  • Removed os.symlink added in # 76. See # 84

Version 0.9.5

  • Fixed a few spelling typos in README. See # 74
  • Fixed example of using –update option in README. See # 74
  • Improved args passing into shim script. See # 75
  • Try to find nodejs if used system-wide node as well. See # 76
  • Added assert if used system-wide node and it wasnt found. See # 76
  • Added -l option into freeze command. See # 71

Version 0.9.4

  • Fixed support for python2.6. See # 70

Version 0.9.3

  • Fixed npm when using prebuilt binaries on Mac OS X. See # 68
  • Fixed using system node under python3.4. See # 43
  • If used system node script bin/node always overwritten

Version 0.9.2

  • Fixed infinite loop when system-wide node used. See # 67

Version 0.9.1

  • Fixed ‘shim’ script if used system-wide node
  • Fixed shebang in the ‘shim’
  • Added shim with name ‘node’ in case of using system-wide node

Version 0.9.0

  • Added shim script. See # 59

Version 0.8.2

  • Fixed prebuilt installation:
    • cp more choosy. See # 64
    • exclude top-level files in prebuilt tar. See # 63

Version 0.8.1

  • Fixed system’s node usage. See # 62

Version 0.8.0

  • Added support for prebuilt packages. See # 56
  • Added support for python3. See # 42

Version 0.7.3

  • Fixed npm.js redirect. See # 52
  • Added --update option. See # 25

Version 0.7.2

  • Bug fixing in freeze. See # 47

Version 0.7.1

  • Added --make option

Version 0.7.0

  • added --force. See # 37
  • python3 support (first steps). See # 38, # 39
  • escaping all directories used by subprocesses. See # 40
  • added an option to use system-wide node. See # 41

Version 0.6.6

  • Fixed incomplete package names using freeze. See # 35
  • Fixed packages installation type in README. See # 33

Version 0.6.5

  • Node’s source not loaded if it already exists in FS.

Version 0.6.4

  • Added python3 compatibility. See # 32

Version 0.6.3

Version 0.6.2

  • Skipped stand-alone npm installation by default. See pull # 30
  • --without-npm has been changed to --with-npm. See pull # 30
  • Fixed options for running Make instances in parallel. See pull # 30

Version 0.6.1

  • Used pkg_resources.parse_version to compare versions. See pull # 29
  • Fixed doubling prompt inside a virtualenv. See issues # 26

Version 0.6.0

  • Fixed typo in deactive command. See pull # 20
  • Not used “–insecure” to download npm. See pull # 21
  • Removed “src” directory after installation. See pull # 22
  • Added option “–clean-src”
  • Added integration with python’s virtualenv. See pull # 23

Version 0.5.3

  • Bug fix. Used https, /dist/latest/. See pull # 16

Version 0.5.2

  • Improved installation logic for release candidate versions. See pull # 10

Version 0.5.1

Version 0.5.0

  • The virtual environment’s path is no longer hardcoded into the activation script. See pull # 13

Version 0.4.3

  • Fixed metavar for --npm
  • npm install -g used for npm >=1.0, not noly for latest

Version 0.4.2

  • Added README.ru.rst

Version 0.4.1

  • Fixed bug in print_node_versions. See pull # 11
  • Added deps in README

Version 0.4.0

  • Compatibility with virtualenv (renamed deactivate to deactivate_node). See pull # 9, issue # 6

Version 0.3.10

  • Fixed bug in url detection for node.js download

Version 0.3.9

  • Deleted notify method calls. See pull # 7
  • Updated tar url for node.js > 0.5.0. See pull # 8

Version 0.3.8

  • Added NODE_PATH variable export (for correct module search after installation via npm)

Version 0.3.7

  • Shows command output when error occurs
  • Excluded ‘npm’ from freeze list
  • Fixed bug with ‘not only letter’ names in freeze list
  • Added global installation for npm >= 1.0 (when install soft from requirement file)

Version 0.3.6

Version 0.3.5

  • Added option --npm to install certain npm.js version. Request .
  • Fixed freeze command for npm >= 1.0.x.

Version 0.3.4

  • Fixed problem #2 with new npm installation script. Added --no-npm-clean option. The default to the npm 0.x cleanup.

Version 0.3.3

  • Fixed problem #1 with installation from PyPI via easy_install. Added MANIFEST.in file.

Version 0.3.2

  • Internal improvements
  • Logging refactoring

Version 0.3.1

  • Default environment promt is folder name

Version 0.3.0

  • Renamed nve to nodeenv
 
File Type Py Version Uploaded on Size
nodeenv-0.13.1.tar.gz (md5) Source 2015-03-17 25KB
  • Downloads (All Versions):
  • 676 downloads in the last day
  • 4690 downloads in the last week
  • 17210 downloads in the last month