Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

fix for pkg.name fields that aren't requirable #2538

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
Contributor

substack commented Jun 19, 2012

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.

Contributor

substack commented Jun 19, 2012

Updated with a less hackish version that I can't even test because the registry is crazy slow right now.

Update: didn't actually work so I force pushed over that commit.

Contributor

substack commented Jun 19, 2012

Setting to null seems like a less-hackish alternative that actually works.

@isaacs isaacs closed this in 9f9d4a5 Jun 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment