This is no secret that node.js package management is terrible, I know packaging is difficult but that doesn’t mean that we have to settle for terrible (I also have issues with python packaging). I feel that a lot of young technologies created some sort of arrogance and people are working again on problems that have been solved in various ways for years.
Those who cannot remember the past are condemned to repeat it.
Anyway, it is difficult to not use node.js if you’re doing anything related to the web. So every time I have to use a node.js library, I isolate it in a python virtalenv using the wonderful nodeenv. Enough for the rant, let’s see how to create a clean container for node.js in a few steps.
$ sudo apt-get install virtualenvwrapper $ sudo apt-get install make curl grep coreutils tar libssl-dev
Then create a container and install nodeenv in it:
$ mkvirtualenv --system-site-packages nodeenv New python executable in nodeenv/bin/python [...] (nodeenv)$ pip install nodeenv Downloading/unpacking nodeenv [...] Successfully installed nodeenv Cleaning up...
Create a local node.js/npm environment inside the current virtualenv (this phase can be lengthy as node.js and npm are downloaded and compiled):
(nodeenv)$ nodeenv -p * Install node.js (0.10.32) ... done. * Appending data to /home/hr/.virtualenvs/nodeenv/bin/activate
Voilà! Nothing crazy difficult here, I now just have to activate my venv to use node.js:
$ workon nodeenv (nodeenv)$ node -v v0.10.32 (nodeenv)$ npm -v 1.4.28
This is more than enough for me but you should check nodeenv’s documentation, there are a lot more options to play with.
[2015/03/05 - EDIT] Fixing typos