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 | 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}.

Marco Louro

About the author

Marco Louro

Marco is an Frontend developer, mostly focused in JavaScript, but with a wide range of interests and a background in various web technologies. He's been with Lincoln Loop since 2008. He first learned about Django in …

Marco is no longer active with Lincoln Loop.