cli
cli copied to clipboard
[BUG] Option engine-strict=true is not compatible with --omit=dev
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
Running npm install --omit=dev with config option engine-strict=true leads to compatibility errors even for dependencies of any kind.
Expected Behavior
While running npm install --omit=dev with config option engine-strict=true npm ignores compatibility errors for dev only dependencies.
Steps To Reproduce
Let's say you have package with package.json manifest
{
"name": "uncompatible-package",
"version": "1.0.0",
"engines": {
"node": ">=100500"
}
}
And you have application package, where you want to have uncompatible-package as dev dependency
{
"name": "application",
"version": "1.0.0",
"devDependencies": {
"uncompatible-package": "./uncompatible-package-1.0.0.tgz"
}
}
And you set engine-strict=true option for your application package
$ npm config set engine-strict true
And when you want to install only production dependencies you have compatibility error
$ npm install --omit=dev
npm ERR! code EBADENGINE
npm ERR! engine Unsupported engine
npm ERR! engine Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Not compatible with your version of node/npm: [email protected]
npm ERR! notsup Required: {"node":">=100500"}
npm ERR! notsup Actual: {"npm":"10.1.0","node":"v20.6.1"}
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sempasha/.npm/_logs/2023-09-14T15_31_44_507Z-debug-0.log
Environment
- npm: 10.1.0
- Node.js: 20.6.1
- OS Name: Fedora Linux
- System Model Name: PC
- npm config:
engine-strict = true
We are also affected by this.
We author packages that still support node 14, 16, ... but we have dev dependencies to build our own packages that only support node 18 and later.
We had hoped to declare these as dev dependencies and use --omit=dev as a fix.
For anyone else landing here, you can work around this by using https://github.com/voxpelli/node-installed-check instead.
@wraithgar Is this still a priority? It looks like it's been marked as a P1 for 18 months.
I've also started hitting this for a dependency. Note that the current npm behavior is a problem without engine-strict also, where it produces a warning instead of an error. It seems silly to me for npm install to produce a warning OR an error for issues with dependent packages that will not be installed (such as devDependencies in the presence of --omit=dev).