Primary image for Installing Node.js and npm into a Python Virtualenv

Installing Node.js and npm into a Python Virtualenv

With things like LESS and RequireJS, we’re starting to use Node.js’s npm (think pip for JavaScript) on every other project. However, installing Node.js globally means some dependencies are also installed globally, which might be a problem if different projects use different versions of the same packages. One solution is to install Node.js/npm inside your virtualenv, so here are the steps to get there:

First off, activate your virtualenv, and:

$ curl http://nodejs.org/dist/node-latest.tar.gz | tar xvz
$ cd node-v*
$ ./configure --prefix=$VIRTUAL_ENV
$ make install

That’s it! Now you can install npm packages directly to your virtualenv path with npm install -g {package}.