Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore incompatible engine "node" error on installing npm dependencies with yarn?

Given this package.json:

{   "name": "yarn-install-fail",   "version": "1.0.0",   "description": "",   "main": "index.js",   "scripts": {},   "author": "",   "license": "ISC",   "dependencies": {     "aws-sdk": "2.x.x",     "s3-streams": "^0.3.0"   } } 

I can install the dependencies successfully via npm:

$ npm install  added 27 packages in 1.844s 

Yet yarn fails:

$ yarn install yarn install v0.24.5 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... error [email protected]: The engine "node" is incompatible with this module. Expected version "^1.2.0". error Found incompatible module info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. 

It appears yarn has trouble installing the library [email protected], yet I assumed it would fallback to install all the dependencies anyway like npm would.

like image 296
k0pernikus Avatar asked Jul 13 '17 18:07

k0pernikus


People also ask

What is yarn -- ignore engines?

The yarn install -ignore-engines command will ignore engines check. This command will ensure that yarn does notinstall optional dependencies. This command run yarn install in offline mode. This command will disable interactive prompts, such as when there's an invalid version of a dependency.

Can you install npm packages with yarn?

Yarn can consume the same package. json format as npm, and can install any package from the npm registry. This will lay out your node_modules folder using Yarn's resolution algorithm that is compatible with the node. js module resolution algorithm.

How do I add npm to yarn?

The Yarn maintainers recommend installing Yarn globally by using the NPM package manager, which is included by default with all Node. js installations. Use the -g flag with npm install to do this: sudo npm install -g yarn.


1 Answers

You can indeed ignore such errors via --ignore-engines:

$ yarn install --ignore-engines yarn install v0.24.5 info No lockfile found. [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. Done in 1.41s. 

This is also documented in the command's help:

$ yarn help | grep -- --ignore     --ignore-scripts                  don't run lifecycle scripts     --ignore-platform                 ignore platform checks     --ignore-engines                  ignore engines check     --ignore-optional                 ignore optional dependencies 
like image 61
k0pernikus Avatar answered Sep 21 '22 11:09

k0pernikus