Last updated: Apr 5, 2024
Reading time·5 min
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.
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.
Open your terminal in your project's root directory (where your package.json
file is) and issue the following command.
yarn install --ignore-engines
If you were trying to install a specific package, use the
yarn global add <package> --ignore-engines
syntax instead.
yarn global add react --ignore-engines
react
with the actual package you're trying to install.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.
yarn config set ignore-engines true
The equivalent npm flag is --force.
npm install --force
Use the following syntax if you need to install a specific package.
npm install react --force
Make sure to replace react
with the name of the package you're trying to
install.
The --force
flag:
engines
declaration requiring a
different version of npm.engines
declaration requiring a
different version of Node.js.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.
# 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.
# 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
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.
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.
node -v
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.
If you are on macOS and use Homebrew, issue the following commands.
# for macOS brew update brew upgrade node brew link --overwrite node
If you use NVM for macOS and Linux to manage your Node.js version, use the following commands.
# NVM for macOS and Linux nvm install --lts nvm use --lts
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.
# NVM for macOS and Linux nvm install 18 nvm use 18
If you use NVM for Windows, use the following commands.
# NVM for Windows nvm install lts nvm use lts
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.
nvm install 18 nvm use 18
If you use GitHub actions, use the following approach to set your Node.js version.
steps: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: node-version: 16
The example sets the Node.js version to 16
.
n
to update your version of Node.jsYou can also use the n package to update your version of Node.js.
npm install -g n n lts
The same approach can be used to install a specific Node.js version.
n 18
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.
Here is the complete stack trace.
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.
"engines": { "node": "16.0.0" },
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.
"engines": { "node": ">=16.0.0" },
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.
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.
You can learn more about the related topics by checking out the following tutorials: