Skip to content
This repository has been archived by the owner on Aug 11, 2022. It is now read-only.

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

Closed
wants to merge 3 commits into from
Closed

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

wants to merge 3 commits into from

Conversation

ghost
Copy link

@ghost ghost 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.

@ghost
Copy link
Author

ghost 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.

@ghost
Copy link
Author

ghost 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant