Tuesday, November 29, 2011

NPM (Node-Package-Manager) Package Install Error

I recently found myself encountering some nearly useless NPM errors when I was trying to install the redis-node package (i.e., Redis.io database connectivity layer for Nodejs), and it did not instantly occur to me why I was seeing error messages during NPM's archive-unpacking operation, especially as the Node-Package-Manager was dumping out a list of errors that made little sense.

Under Linux, NPM install was producing errors that implied I did not have permission to the tmp / temporary directory or directories the package was being unzipped/unpacked into for installation from (i.e., the temporary location the tarball / tar.gz file would be unpacked in). Under Windows, the same NPM install (under git-bash window) produced different errors that made it appear the downloaded .git package could not be unpacked for god knows what reason, all hidden in a massive error dump that had nothing to do with the REAL reason for the error.

Well, I figured out why the errors occurred (as detailed in this blog entry), and I also learned that this NPM software is a perfect example of what I consider a non-user-friendly interface in that it presents the user with all sorts of completely meaningless error messages in the event of very simple-to-detect issues. Bottom line: the node package manager is written by geeks, for geeks. This is not "enterprise grade" software by any means, as it does not have robust error-detection/traps/messages. In fact, the error-traps it does employ seem to mislead more than assist: this is simply poor design. (note: I give credit to ANY open-source effort like this though, and I understand why people focus on other functionality vs. "usability").

Notice the URL I mistakenly specified for the install package... THAT is what causes the error. Yes, something as simple as copying and pasting the incorrect URL from the project's github page will lead to this tragic error-dump.

This is where I went wrong:

...the default URL shown in that textbox on Github (image above) is for the HTTP version of the URL. I had accidentally copied that and pasted to my command prompt for my "npm install" command, where instead I needed to do this:

Now I could copy and paste the proper git:// prefixed URL address of the node_redis.git package that I wanted to install with NPM.

c:\node>node ./npm install -g git://github.com/mranney/node_redis.git

...which produces the simple one-line output as a result of a "successful" package install:

I have been using Node (Nodejs) under OpenSuse 12.1 x64 KDE. When I first encountered this issue under Windows, I quickly jumped over to my Linux VMware virtual-machine to see if for some reason it was a Windows-implementation-only issue (since, Node and NPM have been more mainstream on Linux, and the NPM under Windows is considered "experimental" yet).

This quick test under Linux helped me see the error in my ways quickly, since I encountered a similar mess of misleading error-messages spewing forth from the node-package-manager when I copied and pasted my npm install command to Linux and executed it:

Yes, it failed similarly to the Windows NPM version, but with an error message (pasted here) that sure made it appear like the the "tar" (unpack) command failed for some inability to work with the temp .tgz file created as part of the install process...

Having performed successful node module installs with NPM under my Linux host already, I knew that I must be missing something obvious. And, without any help at all from those meaningless error messages, I finally saw that I pasted the "https://" address of the github node module address instead of the git:// version. Fixing this mistake, the module installed just fine under both Linux and Windows.

This revelation (about my mistaken "https" vs. "git" prefix), coupled with my frustration at misleading NPM error messages, led to the writing of this blog in case anyone else runs into this issue and gets misled by utterly meaningless error messages.

I hope someone working on the NPM (package manager for node) will eventually make time to implement proper condition-testing (and meaningful error-reporting) to test the format of command-line parameters as important as the actual package/module URL if the format makes such a tremendous difference in results. Had this software simply tested the URL for a valid format, and told me "sorry, you must use git:// prefix" or suggested another equally effective alternative, that would be ideal and would save myself, and surely others, from wasting time with misleading error messages.

Redis (Redis.io) Database via Node

As an aside, I can report that I am able to access my Redis (NOSQL) DB from both Linux and Windows versions of Node via the node_redis module's functionality from within Javascript. I hope to add more blog material about my experiences with installing and using Redis with Node at a later date.

About Me

I have spent much of my life working with computers, technology, programming, software development, and business consulting. I have a strong attachment to technology and science in general.

My interests and insight go well beyond computers though, as you will soon discover while you peruse my blog entries covering topics from finance to gluten free diets. I have even recently authored a Gluten-Free Dessert Recipes Cookbook of gourmet quality desserts for Celiacs and Wheat-Free / Gluten-Free individuals.

Note: This site is not intended for use as a source of technology, health, legal, or professional advice, and I assume no responsibility for errors, inaccuracies, omissions, or any thing else resulting from you reading this blog. All content is copyrighted with all rights reserved.