The engine "node" is incompatible with this module

Viewed 293636

I am getting below yarn error when deploying to AWS

error fs-extra@7.0.1: The engine "node" is incompatible with this module. Expected version ">=6 <7 || >=8". Got "7.0.0"

Any idea how will this be resolved?

Will this work out if I specify engine in package.json

{ 
  "engines" : { 
    "node" : ">=8.0.0" 
  }
}
17 Answers

You can try to ignore the engines :

$ yarn install --ignore-engines

OR

$ yarn global add <your app> --ignore-engines

You can see all what you can ignore by running:

$ 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

You need to upgrade your version of node.

I ran into this same issue.

If you used Homebrew run:

brew update  # This updates Homebrew to latest version
brew upgrade node

If you use nvm run:

nvm current node -v  # Checks your current version
nvm install <version>  # Example: nvm install 12.14.1

For the above step go to https://nodejs.org/en/download/

Grab a version which satisfies the conditionals in your error, the latest version should work.

More Detailed Walkthrough: https://flaviocopes.com/how-to-update-node/

A fix that is a hack can be

yarn config set ignore-engines true

However if you want a permanent solution is to :

  1. delete node_modules/, package-lock.json & yarn.lock
  2. run yarn install or npm i again.

Add --ignore-engines to the suffix while installing the package like this:

yarn add <package_name> --ignore-engines

My problem was solved with yarn --ignore-engines, but I'm not sure why and how.

I had a similar issue on Ubuntu even after installing Nodejs many times with the latest version, it was showing always the same old Nodejs version; I discovered it was installing the similar old Debian package each time, even after executing the apt-get update command

Finally, I got it to work by purging the old nodeJs then adding different repository source, and installing nodeJs normally with the new distribution as follows:

sudo apt-get purge --auto-remove nodejs
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

Please find the list of all NodeJs distribution below https://github.com/nodesource/distributions/blob/master/README.md

You may find other ways of doing the update, but this one worked for me.

You can try:

  1. Open you package.json
  2. find "engines": { "node": "14.x" }
  3. change 14.x -> >=14.x

I do NOT recommend using this:

% yarn install --ignore-engines

It avoids the issue instead of solving it.
A possible solution would be to update your node to version > 8.0.

% brew upgrade node

Or you could try installing multiple versions of node by using nodenv, in case you need them for other projects.

% brew install nodenv
% nodenv init
# Load nodenv automatically by appending
# the following to ~/.zshrc:

eval "$(nodenv init -)"
% nodenv install 6.0.0 //or some other version

I recommend doing what the error message says and checking your Node.js version (node -v). The easiest way to upgrade Node.js is with the n version manager:

$ npm install -g n

Then install the latest (n latest) or LTS (n lts) version of Node.

sudo npm cache clean -f
sudo npm install -g n
sudo n 10.22.1
node -v => Should be on 10.22.1

type what version of node you require as I have just put 10.22.1 as an example

Lots of answers say to set flags to ignore the version error.

A better option is to use this as a reminder to update your node version to something recent and supported by the package you want to install.

nvm install 16.16.0  # download & install locally on your system
nvm use 16.16.0      # update current project's .nvmrc file

Note that the 2nd command will update your local .nvmrc which specifies a per-project node version.

The node ecosystem turns over quickly, even "Long Term Support" (LTS) releases stop getting support after about 3 years. Use this page to see the latest LTS release version, and also make sure it matches the node version expected by the package you're installing, from the error message.

I found this problem now, with an old code, however, I solved it with: yarn upgrade

Just found that not only I need to upgrade the node, but also need to install it.

This upgrades node to latest version:

brew upgrade node

This install the specific version of node:

nvm install 17.0.0

This is a lot more problematic than it seems on the surface.

If you include a module that requires node 6, but you have other modules that use node 11, you will get this error!

It's problematic when it's 3rd party modules you've used nom/yarn/etc. to install, as you don't have access to those package repos without doing git fork.

In my case, I am using yarn workspaces and some of the modules in the package.json files in the workspaces might require foo 1.0 while others require foo 2.0 and the 1.0 version might require node 6 and the 2.0 version might require node 14.

The only solution I found is to use --ignore-engines, though it clearly is what other(s) have posted - that this is not fixing the problem, just ignoring it in spite of any issues that might be caused (node 6 code might not run on node 14!).

Upgrade your version of node , this issue will be resolved

Related