More Node.js answers

by Danny
Published 2 min read

This error means a package's engines field asks for a different Node version than you are running. Learn how to read it, switch versions with .nvmrc and pin your package manager.

The short answer

#

A package you are installing says, in its engines field, which Node versions it supports, and your current Node is outside that range. Switch to a version that matches, ideally the one your project pins in .nvmrc, then install again.


_10
node --version
_10
_10
# Switch to the version in .nvmrc (or install it)
_10
nvm install
_10
nvm use
_10
_10
rm -rf node_modules
_10
npm install

Why it happens

#

Packages can declare the Node versions they work with in package.json:


_10
{
_10
"engines": {
_10
"node": ">=22"
_10
}
_10
}

Package managers compare that range with the Node you are running. The exact message depends on the tool:


_10
# Yarn 1
_10
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=22". Got "20.18.0"
_10
_10
# npm
_10
npm warn EBADENGINE Unsupported engine { package: '[email protected]', required: { node: '>=22' }, current: { node: 'v20.18.0' } }

Yarn 1 stops the install. npm only warns, unless engine-strict is turned on. pnpm warns for dependencies and fails if your own project's engines does not match.

This error is showing up more often now because Node 20 reached end of life in April 2026, and many packages have raised their minimum to Node 22 or later. The current LTS lines are Node 24 and Node 26, with Node 22 in maintenance until April 2027.

How to fix it

#

Upgrade Node with a version manager

The right fix is almost always to use a supported Node version. With nvm or fnm you can install one next to your current version:


_10
nvm install --lts
_10
nvm alias default lts/*

In CI, set the version explicitly, for example node-version-file: .nvmrc in the actions/setup-node step on GitHub Actions.

Pin the version for the whole team

Add a .nvmrc file at the project root so everyone uses the same major version. nvm and fnm both read it, and fnm also reads .node-version.


_10
echo "24" > .nvmrc

Then state the same range in your own engines field, so anyone on the wrong version gets told straight away:


_10
{
_10
"engines": {
_10
"node": ">=24"
_10
}
_10
}

To make npm fail instead of warn, add an .npmrc file to the project:


_10
echo "engine-strict=true" >> .npmrc

Pin the package manager too

Version mismatches sometimes come from the package manager rather than Node, for example a different major version of pnpm or Yarn. Record the exact version in the packageManager field:


_10
{
_10
"packageManager": "[email protected]"
_10
}

Corepack reads this field and runs that exact version. It ships with Node 24 and earlier, but it is no longer bundled from Node 25, so on Node 26 install it first:


_10
npm install -g corepack
_10
corepack enable

Use an older package version as a stopgap

If you really cannot upgrade Node yet, install the last version of the package that supports yours. Check its changelog to find it.


_10
npm install some-package@2

Ignore the check only as a last resort

Yarn 1 has --ignore-engines. It gets the install through, but the package may use APIs your Node does not have and fail at runtime, so treat it as temporary.

Common pitfalls

#
  • Switching Node and keeping the old node_modules. Native modules are compiled for a specific Node version; reinstall after switching.
  • Having a .nvmrc but never running nvm use. Set up your shell to switch automatically, or use fnm with --use-on-cd.
  • A CI image with a different Node version from your laptop. Read the version from .nvmrc in CI too.
  • Setting engines to an exact version such as 24.3.0. Use a range so patch updates still work.
  • Turning off the check globally with engine-strict=false and forgetting about it.
#

Was this resource helpful?