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

npm does not dupe modules after install causing invalid node_modules tree #5465

Closed
Raynos opened this issue Jun 11, 2014 · 3 comments
Closed
Labels
Milestone

Comments

@Raynos
Copy link
Contributor

Raynos commented Jun 11, 2014

When you npm install a module A, npm install may dedupe any of module A's dependencies if they already exist in the node_modules tree.

Now if you were to install a newer version of the deduped module in the tree npm does not go and find all the locations where it deduped the module deeper in the tree and install the old version if its a semver range mismatch

Example

cd ~/tmp
mkdir foobar
cd foobar
npm init
npm i negotiator@0.2.5 -S
npm i st -S
npm i negotiator@latest -S
npm ls
echo $?; 1

Expected output

any npm install --save should not cause an npm ls to fail after the install. (assuming npm ls worked before the install)

Suggested fix

  • we can update npm install {{module}}@version so that it searches the entire dependency tree (based on package.json, not node_modules) for all references to {{module}}. We can then manually check that each referenced range matches the new version and if it does not invoke npm install {{module}}@range in that location in the node_modules tree
  • we can remove the deduping feature from npm install

cc @isaacs @othiym23

@Raynos
Copy link
Contributor Author

Raynos commented Jun 11, 2014

cc @domenic

@Raynos
Copy link
Contributor Author

Raynos commented Aug 15, 2014

Other suggested fix:

  • make npm ls point very concretely at the problem. it just says invalid negotiator without saying that "there is a conflict between st and negotiator".

Also @isaacs this is an example of dependency hell, we are not supposed to have version conflicts ever.

@iarna
Copy link
Contributor

iarna commented Dec 12, 2014

This is going to be fixed by #6912 and #6913. As such, I'm going to close this ticket and any further discussion should occur in them.

@iarna iarna closed this as completed Dec 12, 2014
@npm npm locked and limited conversation to collaborators Jun 24, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants