isaacs/npm — pull request #2538 by substack (2012-06-19 06:12:12+00:00)
Title: fix for pkg.name fields that aren't requirable

Sometimes a package.json will have a `"name"` field set but won't be in a node_modules directory or will have a different basename than the name field, rendering the package unrequirable by subdependencies that wrongly assume the package is already available and won't pull down a local version from the registry.

I encountered this problem running the tests for js-traverse, which uses tap, but tap depends on difflet which depends on traverse. npm didn't fetch traverse as a dependency for difflet, causing my tests to fail with: `Couldn't find module "traverse"`

This patch tacks on a tap test into test/tap and adds `&& tap tests/tap/*.js` to the scripts.test since the existing test stuff seemed non-obvious where to start with. The change itself is a relatively minor yet hackish check in lib/install.js that tacks on some random garbage to the end of the `data.name` so that subdependencies won't wrongly assume they already have a package that they won't be able to require(). There's probably a better way to fix this but this way works and all the existing tests pass.