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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thedata.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.