isaacs/npm — pull request #3072 by CarlQLange (2013-01-18 05:11:26+00:00)
Title: Added ENOTDIR check to install#targetResolver

We had a repo which shipped with a node_modules directory, and inside this directory was a .gitignore file.

This led to `npm install` attempting to install the .gitignore file as a package This made npm hang, instead of erroring out, as there was no handling for ENOTDIR and the default error handler didn't act correctly. This bug was introduced in npm v.1.1.71, roughly in commit 00f781f6.

This pull request adds an ENOTDIR check next to the ENOENT check, thus correctly handing any non-directory files that already exist in the node_modules directory.

There may need to be more checks for other places - or the problem may in fact be the error handler, not targetResolver.

Let me know if there's anything I can help with!