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
- Check for known devDependency "ava" and notice that it has been installed:
npm ls -a | grep 'ava'
> ├─┬ ava@3.15.0 extraneous
npm prune --production removes the ava package. But a following npm install will install it again
It 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 by npm shrinkwrap during publishing of the @ui5/cli package. This basically removed all devDependencies from the npm-shrinkwrap.json (see UI5/cli#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:
Environment
- npm: v8.3.2
- Node.js: v16.13.2
- OS Name: macOS 12.1 (Monterey)
- System Model Name: MacBook Pro
- npm config:
registry = "https://registry.npmjs.com/"
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": trueare installed unexpectedly.Expected Behavior
devDependenciesof 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-testnpm installnpm prune --productionremoves theavapackage. But a followingnpm installwill install it againIt seems that after installing
@ui5/cli@nextin 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 --productionfollowed bynpm shrinkwrapduring publishing of the@ui5/clipackage. This basically removed all devDependencies from the npm-shrinkwrap.json (see UI5/cli#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>sdevDependenciesif the package has a publishednpm-shrinkwrap.json#1878npm install --productiondoes not install the dependency'sdevDependencies. However, I would expect this exact behavior fromnpm install(without the--productionflag) since I don't see a point in installing transitivedevDependenciesEnvironment