-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[BUG] devDependencies of project with npm-shrinkwrap.json are getting installed #4323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm going to +1 this via comment as well for visibility: I just worked around this in part of our build process for |
confirmed bug, we're ignoring the i confirmed the as noted, as a further note, |
@nlf any chance that this can get prioritized? Another interesting issue that comes with this is that |
It's also quite frustrating with Dependabot updates, because Dependabot uses |
This is something that we're scratching our head to solve. Installing all our dev dependencies when installing It'd be really appreciated if this could be addressed soon! Thanks! |
Another week, another person surprised when dev dependencies are installed and it triggers other |
Once again, another person has escalated an issue to me where the dev dependencies are being installed. Would love to see this addressed soon. |
Is there any timeline for this issue? It's pretty confusing to see so many irrelevant errors/warnings. |
Commenting for visibility. Not sure if you're responsible @nlf but this deserves some attention. |
This issue has been opened for a while now and we still see those irrelevant warnings and errors. Can this be prioritized and fixed in the near future? Thanks! |
I've given up on this ever being fixed and worked around it using |
Fixes issue #1799. We use npm shrinkwrap to try and improve security for users, however the shrinkwrap file includes dev dependencies, and a bug in npm [[1]] means that users are getting the dev dependencies whenever they create a new prototype. This commit changes the publishing process so that these dev dependencies are removed from package.json and npm-shrinkwrap.json, using the tool [clean-publish]. [1]: npm/cli#4323 [clean-publish]: https://github.com/shashkovdanil/clean-publish#readme
Update: This can still be reproduced as described with Node |
We've also just noticed that with the most recent versions of node (22.11 & 23.2) and npm (10.9.0). node -e 'const pkg = require("./package.json"); delete pkg.devDependencies; fs.writeFileSync("./package.json", JSON.stringify(pkg, null, 2))'
npm prune --omit=dev
npm shrinkwrap |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When installing a package (
npm install <package name>
) from the npm registry that contains an npm-shrinkwrap.json, dependencies listed with"dev": true
are installed unexpectedly.Expected Behavior
devDependencies
of the published package should not be installed when consuming the package.Steps To Reproduce
Given: Node.js v16.13.2 and npm v8.3.2
I created an example project to showcase this issue: https://github.com/RandomByte/npm-shrinkwrap-test
git clone git@github.com:RandomByte/npm-shrinkwrap-test.git && cd npm-shrinkwrap-test
npm install
npm prune --production
removes theava
package. But a followingnpm install
will install it againIt seems that after installing
@ui5/cli@next
in the empty project, its devDependencies where installed as normal dependencies. This is unexpected since a consumer of the package does not need its devDependencies.In the past (with npm v6) we worked around this issue by executing
npm prune --production
followed bynpm shrinkwrap
during publishing of the@ui5/cli
package. This basically removed all devDependencies from the npm-shrinkwrap.json (see SAP/ui5-tooling#283 (comment)). But this does not seem to work with npm v8 anymore, as the npm-shrinkwrap.json is not being updated after the prune took place.I think the fundamental issue is present since at least npm v6. Relevant issues are:
npm install <package-name>
will install that <package>sdevDependencies
if the package has a publishednpm-shrinkwrap.json
#1878npm install --production
does not install the dependency'sdevDependencies
. However, I would expect this exact behavior fromnpm install
(without the--production
flag) since I don't see a point in installing transitivedevDependencies
Environment
The text was updated successfully, but these errors were encountered: