cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] NPM --omit=optional results in dependency version not being installed

Open flanagansshenanigans opened this issue 1 year ago • 0 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

Have installed a local package into optional, while also have an alternative path in the "dependencies" section of package.json

Running the install command with no flag: npm install node node_modules/node-red/red.js

image

Results in the "lower-case2" function showing in node-red. Also if I remove "lower-case": "file:./lower-case2" from "optionalDependencies" and re-run the above commands the result in similar to the previous behavior except "lower-case2" becomes "lower-case"

image

Now when I run install with the flag omit for optional dependencies: npm install --omit=optional node node_modules/node-red/red.js

The result is that neither "lower-case" or "lower-case2" shows under the functions panel.

image

Expected Behavior

I expect that when I omit optional dependencies, that the package under the same name but in the "dependencies" section of package.json to install.

Commands: npm install --omit=optional node node_modules/node-red/red.js

Expect: "lower-case" to show in the functions panel.

image

Steps To Reproduce

  1. Go to https://stackblitz.com/edit/stackblitz-starters-d1ax1g?file=package.json
  2. Run 'npm install'
  3. Run 'node node_modules/node-red/red.js'
  4. See error

Environment

  • npm: 10.2.3 + 10.7.0
  • Node.js: 18.20.3 + 20.15.0
  • OS Name: Windows 11

flanagansshenanigans avatar Jun 29 '24 06:06 flanagansshenanigans