This repository was archived by the owner on Aug 11, 2022. It is now read-only.
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
dedupe + shrinkwrap not playing nice #5161
Closed
Description
npm install de-duplicates any nested dependencies it finds if they exist higher up the tree.
This causes issues if you de-duplicate a nested dependency when it is a devDependency of it's parent.
Especially if that parent runs npm shrinkwrap
and shrinkwraps all dependencies except dev dependencies;
Consider:
mkdir foobaz;
cd foobaz/;
npm init;
npm i individual@0.1.1 --save-dev;
npm i data-set --save;
npm ls; # no errors
npm shrinkwrap; # dont shrinkwrap devDeps
cat npm-shrinkwrap.json; # no individual anywhere
rm -rf node_modules/;
npm i --production;
npm ls; # npm ERR! missing: individual@~0.1.1
We generated a shrinkwrap and installed freshly from it and our node_modules tree is in an incorrect state.
Suggested fix
- do not have npm install dedupe if a parent dependency is a dev dependency.
- have npm shrinkwrap bail and shout about this inconsistency.
I think the first suggestion is a good fix, I'm willing to make a PR to avoid deduping if a parent dependency is a dev dependency.