People who know me know I'm a fan of Node.JS, the "JavaScript on the server" development framework. And while I would love to say it's all sweetness and light in Node-Land, sometimes there are some dark clouds. One of the darkest current clouds is version dependencies. It's not as bad as it used to be, but every now and again we still get a situation where we might want to punt on the latest version and use the "most recent version that exhibits a particular behaviour."
But the way node is packaged on Debian (and Raspbian) you generally get an old version installed directly in /usr. At Smithee, et al, we've taken a slightly different tack. We install node in /opt/node-v$VERSION with soft-links scattered throughout the file-system to point back to /opt.
For example, on my Raspberry Pi right now, I have two versions of node v0.10.26 and v0.6.5 (yeah. don't ask.) So, /opt on my machine contains the following node-related directories:
Then I added some soft links to make the system think i had installed version 0.10.26 in /usr:
So if I want to use version 0.10.26, i use node normally. But if I need to use version 0.6.5, i put /opt/node-v0.6.5/bin in the path before /usr. And when version 0.10.27 comes out, i install it in /opt/node-v0.10.27 and point /opt/node to point to there. If it turns out I have to revert for some reason, all I have to do is change /opt/node to point back to /opt/node-v0.10.26.
If you want to try this out yourself, here's a .deb file you can install with the command `sudo dpkg -i nodejs_0.10.26-1.armhf.deb`. Or, if you like tar files, here is a tar file with node v0.10.26 you can install with the command `( cd /; sudo tar xzvf node_v0.10.26_raspian.tar.gz )`. Both should work with a stock 2014-01-07-wheezy-raspbian system.
But the way node is packaged on Debian (and Raspbian) you generally get an old version installed directly in /usr. At Smithee, et al, we've taken a slightly different tack. We install node in /opt/node-v$VERSION with soft-links scattered throughout the file-system to point back to /opt.
For example, on my Raspberry Pi right now, I have two versions of node v0.10.26 and v0.6.5 (yeah. don't ask.) So, /opt on my machine contains the following node-related directories:
| Directory | What's There |
|---|---|
| /opt/node-v0.10.26 | Modern, daily use node installation |
| /opt/node-v0.6.5 | Legacy node installation |
Then I added some soft links to make the system think i had installed version 0.10.26 in /usr:
| From | To | Description |
|---|---|---|
| /opt/node | /opt/node-v0.10.26 | Current default node |
| /usr/bin/node | /opt/node/bin/node | Node executable |
| /usr/include/node | /opt/node/include/node | Node include files |
| /usr/lib/node_modules | /opt/node/lib/node_modules | Node modules (including npm) |
| /usr/lib/dtrace/node.d | /opt/node/lib/dtrace/node.d | dtrace descriptor for node |
| /usr/share/man/man1/node.1 | /opt/node/share/man/man1/node.1 | Man page for node |
So if I want to use version 0.10.26, i use node normally. But if I need to use version 0.6.5, i put /opt/node-v0.6.5/bin in the path before /usr. And when version 0.10.27 comes out, i install it in /opt/node-v0.10.27 and point /opt/node to point to there. If it turns out I have to revert for some reason, all I have to do is change /opt/node to point back to /opt/node-v0.10.26.
If you want to try this out yourself, here's a .deb file you can install with the command `sudo dpkg -i nodejs_0.10.26-1.armhf.deb`. Or, if you like tar files, here is a tar file with node v0.10.26 you can install with the command `( cd /; sudo tar xzvf node_v0.10.26_raspian.tar.gz )`. Both should work with a stock 2014-01-07-wheezy-raspbian system.
No comments:
Post a Comment