Cli: [BUG] packages that are in `devDependencies` AND `optionalDependencies` are automatically added to package.json's `dependencies` on `npm install`

Created on 1 Oct 2020  路  1Comment  路  Source: npm/cli

Current Behavior:

Packages that are in devDependencies AND optionalDependencies are automatically added to package.json's dependencies on npm install.

Expected Behavior:

npm install shouldn't edit the package.json.

npm v6 docs states that Entries in optionalDependencies will override entries of the same name in dependencies, so it鈥檚 usually best to only put in one place. (https://docs.npmjs.com/files/package.json#optionaldependencies)

Steps To Reproduce:

  1. npm init -y
  2. npm install noop --save-optional
  3. npm install
  4. view package.json and see that the optional dependency was added to dependencies.

Environment:

  • OS: Kubuntu 20.04
  • Node: 14.13.0
  • npm: 7.0.0-rc.0
Bug Release 7.x beta

Most helpful comment

I am noticing this same issue on npm 7.0.6, except it happens for packages with are only in optionalDependencies.

>All comments

I am noticing this same issue on npm 7.0.6, except it happens for packages with are only in optionalDependencies.

Was this page helpful?
0 / 5 - 0 ratings