I tried to specify the node engine in a package.json to accept both 8
and 10
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
?
What are Node Engines? Node engines are a little discussed (but in my opinion pretty critical) configuration that can be specified in your package. json file that tells anyone (or any machine) running the JavaScript application which version of Node is required for the code to work.
The package. json file is the heart of any Node project. It records important metadata about a project which is required before publishing to NPM, and also defines functional attributes of a project that npm uses to install dependencies, run scripts, and identify the entry point to our package.
A package. json file must contain "name" and "version" fields. The "name" field contains your package's name, and must be lowercase and one word, and may contain hyphens and underscores. The "version" field must be in the form x.x.x and follow the semantic versioning guidelines.
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" } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With