Node engine 8.x or 10.x in package.json
66,896
Solution 1
You just need the double pipe ||
instead of a single.
"engines": {
"node": "^8 || ^10"
}
Would match either v8.x.x or v10.x.x but not v9.
You can read more about it here https://docs.npmjs.com/files/package.json#dependencies
Solution 2
See the documentation which includes examples.
Provide a space separated list of engines with greater/less than symbols.
{
"engines" : {
"node" : ">=8.0.0 <11.0.0"
}
}
Author by
rap-2-h
Laravel enthusiast & Rust artisan. Resume: https://raph.site/en
Updated on August 12, 2021Comments
-
rap-2-h almost 3 years
I tried to specify the node engine in a package.json to accept both
8
and10
version.I tried to type this:
"engines": { "node": "8.x|10.x" },
But running
yarn
results in:The engine "node" is incompatible with this module. Expected version "8.x|10.x"
If I replace with:
"engines": { "node": "10.x" },
... it works (i.e no error).
Is there a way to accept two versions of node engine in a
package.json
? -
Flygenring over 5 yearsAs this includes the requested node versions it's exactly wrong, but it doesn't solve the actual problem as it would also include all of 9.x, which seems to be the actual problem here?
-
Crypto Batman about 3 yearsIf you have two constraints like shown here... read "greater than 8 and less than 11" you can use a space. If you want to have multiple variants you must use the
||