The engine "node" is incompatible with this module [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
5 min

banner

# Table of Contents

  1. The engine "node" is incompatible with this module
  2. Ignoring the engines check with YARN
  3. Ignoring the engines check with NPM
  4. Delete node_modules, yarn.lock and package-lock.json
  5. Updating your version of Node.js
  6. npm WARN EBADENGINE Unsupported engine

# The engine "node" is incompatible with this module

The error 'The engine "node" is incompatible with this module' occurs when the package you are trying to install is not compatible with your Node.js engine (version).

To solve the error, run the yarn install command with the --ignore-engines flag.

shell
error package@version: The engine "node" is incompatible with this module. Expected version "^14 || >=16.0.0 || ^18". Got "X.Y.Z". error Found incompatible module.

The "engine" Node refers to your version of Node.js.

You can use the node -v command if you need to check your version.

# Ignoring the engines check with YARN

Open your terminal in your project's root directory (where your package.json file is) and issue the following command.

shell
yarn install --ignore-engines

yarn install ignore engines

If you were trying to install a specific package, use the yarn global add <package> --ignore-engines syntax instead.

shell
yarn global add react --ignore-engines
Make sure to replace react with the actual package you're trying to install.

install specific package with ignore installed

The --ignore-engines flag is used to ignore the engines check.

If you want to ignore the --ignore-engines check globally (for all commands), issue the following command.

shell
yarn config set ignore-engines true

ignore engines check globally

# Ignoring the engines check with NPM

The equivalent npm flag is --force.

shell
npm install --force

npm install with force flag

Use the following syntax if you need to install a specific package.

shell
npm install react --force

Make sure to replace react with the name of the package you're trying to install.

The --force flag:

  • allows installing packages that have an engines declaration requiring a different version of npm.
  • allows installing packages that have an engines declaration requiring a different version of Node.js.

# Delete node_modules, yarn.lock and package-lock.json

If the error persists, try to delete the node_modules folder, the yarn.lock file and the package-lock.json file.

If you are on Windows, issue the following commands.

shell
# Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # clean your npm cache npm cache clean --force npm install

If you are on macOS or Linux, issue the following commands.

shell
# macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # clean your npm cache npm cache clean --force npm install

# Updating your version of Node.js

An alternative approach to solving the error is to update your version of Node.js.

The error basically means that the required by the package Node.js version is not compatible with your Node.js version.

shell
Expected version "^14 || >=16.0.0 || ^18". Got "X.Y.Z". error Found incompatible module.

Notice that the error message specifies the expected by the package versions.

You can use the node -v command to check your Node.js version.

shell
node -v

check node version 19

If your version of Node is not one of the supported versions, you have to update it to one of the versions in the specified range.

For example, 14 || 16 || 18 means that the supported versions are 14.X.X, 16.X.X and 18.X.X.

Similarly, if the error message expects a version ">=18", then you have to install Node.js version 18 or greater.

One way to update your version of Node.js is to download the installer from the official nodejs.org website.

# Using brew on macOS

If you are on macOS and use Homebrew, issue the following commands.

shell
# for macOS brew update brew upgrade node brew link --overwrite node

# Using NVM to update your Node.js version

If you use NVM for macOS and Linux to manage your Node.js version, use the following commands.

shell
# NVM for macOS and Linux nvm install --lts nvm use --lts

nvm install lts macos linux

I have written a step-by-step guide on how to install NVM on macOS and Linux.

The command installs the long-term supported Node.js version.

You can also install a specific version.

shell
# NVM for macOS and Linux nvm install 18 nvm use 18

nvm install specific version macos linux

If you use NVM for Windows, use the following commands.

shell
# NVM for Windows nvm install lts nvm use lts

nvm install lts version windows

I have written a step-by-step guide on how to install NVM on Windows.

The same approach can be used to install a specific Node.js version.

shell
nvm install 18 nvm use 18

nvm windows install specific version

# Updating your Node.js version in GitHub actions

If you use GitHub actions, use the following approach to set your Node.js version.

github-actions.yml
steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16

The example sets the Node.js version to 16.

# Using n to update your version of Node.js

You can also use the n package to update your version of Node.js.

shell
npm install -g n n lts

The same approach can be used to install a specific Node.js version.

shell
n 18

# npm WARN EBADENGINE Unsupported engine

If you get the warning "npm WARN EBADENGINE Unsupported engine", then you either have set the engines property incorrectly in your package.json file or the package you are trying to install does not support your Node.js version.

npm warn ebadengine unsupported engine

Here is the complete stack trace.

shell
npm WARN EBADENGINE Unsupported engine { npm WARN EBADENGINE package: 'my-package@1.0.0', npm WARN EBADENGINE required: { node: '16.0.0' }, npm WARN EBADENGINE current: { node: 'v18.15.0', npm: '9.5.0' } npm WARN EBADENGINE }

For example, my package.json file has the following engines object set.

package.json
"engines": { "node": "16.0.0" },

engines property set in package json

The only version that the package supports is Node.js version 16.0.0. Trying to install it with any other version raises the warning.

If the engines property is set in your package.json file, you can update it to resolve the issue.

package.json
"engines": { "node": ">=16.0.0" },

engines property set correctly

Now the warning isn't shown when you try to run npm install with a Node.js version greater than 16.

If the engines property is not set in your package.json file, you have to update your version of Node.js based on the error message.

shell
npm WARN EBADENGINE required: { node: '16.0.0' }, npm WARN EBADENGINE current: { node: 'v18.15.0', npm: '9.5.0' }

The error message above means that the package requires Node.js version 16.0.0, however, version 18.15.0 is installed.

In this case, you have to install Node.js version 16.0.0 as shown in the previous subheading.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.