Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node engine 8.x or 10.x in package.json

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?

like image 246
rap-2-h Avatar asked Jul 30 '18 14:07

rap-2-h


People also ask

What is a Node engine?

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.

How does Node use package json?

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.

What should I put in package json?

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.


1 Answers

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"    } } 
like image 198
Quentin Avatar answered Oct 14 '22 23:10

Quentin