How to ignore incompatible engine "node" error on installing npm dependencies with yarn?
node.jsNpmNpm InstallYarnpkgnode.js Problem Overview
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 s3-streams@0.3.0: 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.
node.js Solutions
Solution 1 - node.js
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
Solution 2 - node.js
yarn config set ignore-engines true
is a one time fix for the "the engine node is incompatible with this module" problem. Once that is completed, you can do "create-react-app my-app"
Solution 3 - node.js
--ignore-engines
doesn't work with the yarn start
command
So there are two solutions for that to get rid of it.
check your node version with:
> node -v
check your npm version with:
> npm -v
Open package.json and make sure the values you got from running the two commands above match with the versions of node
and npm
in the engines
object.
OR
You can simply remove engines
from the package.json file otherwise it will always check the version to match.
Solution 4 - node.js
add --ignore-engines
to remove the errors
$ yarn help
....
--ignore-scripts don't run lifecycle scripts
--ignore-platform ignore platform checks
--ignore-engines ignore engines check
--ignore-optional ignore optional dependencies
....
Solution 5 - node.js
If you run into this problem, it might be because
you have several versions of node
on your system.
For example, you might have run some command that installs an uptodate version of node in one place, but be running a different version of node because it's directory is ahead of the other one in $PATH.
So it might be a good idea to run
which -a node
If the nvm version is out-of-date, you could update it, e.g.
to a particular version: nvm install 15.4.0