Skip to content

Instantly share code, notes, and snippets.

@dgowrie
Created August 9, 2018 15:51
Show Gist options
  • Select an option

  • Save dgowrie/aa82fc4a0f043f55e93c6994d41d0904 to your computer and use it in GitHub Desktop.

Select an option

Save dgowrie/aa82fc4a0f043f55e93c6994d41d0904 to your computer and use it in GitHub Desktop.
Node in Python virtualenv

From: http://bocribbz.com/post/80417240179/nodejs-in-pythons-virtualenv

Virtualenv is very useful tool, it helps with isolation and solves some redundant administrative works. Node.js also has similar tools, but from them, one stands apart, nodeenv.

What is really great about nodeenv, is that it helps you avoid typing long source commands, and if you are used to virtualenvwrapper, you dont have to learn a new set of commands.

To install it you can follow these quick steps, after you have installed virtualenv and virtualenvwrapper.

$ mkvirtualenv node_proj
(node_proj)$ pip install nodeenv # install nodeenv in the py virtualenv
(node_proj)$ nodeenv -p # install nodejs and add new function to virtualenvwrapper
* Install node.js (0.10.26) ... done.
* Appending nodeenv settings to /opt/node_proj/shared/env/node_proj/bin/activate
(node_proj)$ deactivate; workon node_proj # reactivate to use the new functions

You now have a nodejs and a python isolated environment, and when you run npm install -g commands, it installs the packages in the node virtual env.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment