[BUG] NPM --omit=optional results in dependency version not being installed
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
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"
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.
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.
Steps To Reproduce
- Go to https://stackblitz.com/edit/stackblitz-starters-d1ax1g?file=package.json
- Run 'npm install'
- Run 'node node_modules/node-red/red.js'
- See error
Environment
- npm: 10.2.3 + 10.7.0
- Node.js: 18.20.3 + 20.15.0
- OS Name: Windows 11