Now that webOS 2.0 ships with Node.js, one of the first things I tried to do when I got the webOS 2.0 SDK a while back was get npm installed. While successful, it took a little bit of work, so figured it was worth a post to help aid anyone else trying to get it installed. For those that aren’t familiar with npm, it is a package manager for Node.js (Node Package Manager).

In short, it’s a easiest way to get Node.js modules installed on your system. It is Node’s equivalent to Ruby’s Gems, Ubuntu’s APT, PHP’s PEAR, and Perl’s CPAN. So instead of manually downloading libraries/modules, explicitly including them in your source code, and having to manually resolve dependency issues, you can just let npm handle that for you. Now, installing a new module is as easy as typing npm install <module>. The version of Node.js that webOS 2.0 ships with (at the moment) is v0.1.102, which is rather old. The build scripts for the latest npm installer does not work with older versions of Node.js, so with trial and error, the most recent version I’ve been able to install on webOS 2.0 is npm v0.1.23. Luckily it’s pretty easy to install that specific version, so here’s how you do it on your webOS device.

If you are looking for a list of packages, check out http://npm.mape.me/. Or, you can just type npm ls. Are there any plans for npm to be included in webOS? HP/Palm engineers confirmed at the webOS Developer Day event a few weeks ago that there are no plans for npm to ship with webOS. That’s fine with me. Modules should be included in the application package anyways.