yarn fails in GitHub Actions: the engine node is incompatible with this module
The engine "node" is incompatible with this moduleShort answer
The Node version on the runner is older or newer than the engines range of a dependency. The Borales yarn action expects you to set up Node yourself first. Add actions/setup-node with an explicit node-version before the yarn step, or point it at a version file in the repo.
Fix it fast
1Find out which cause you have
Print the Node version the job really uses and the range the failing package asks for.
node --version node -p "require('./package.json').engines"2Match what you see, then jump to its fix
- 1
node --version in the job shows whatever Node is on the runner, not your project'sNo Node version is set before the yarn stepFix - 2
Your repo has .nvmrc or .node-version, but the workflow names another versionThe version differs from the one the project is built withFix - 3
The project is on Yarn 2 or later (a .yarnrc.yml file in the repo)The action is used with a newer Yarn than it supportsFix
- 1
What does the error look like?
The engine "node" is incompatible with this module
Cause 1 of 3
No Node version is set before the yarn step
1Check
setup-node uses the Node found on PATH when node-version is not given, and Borales' README says to run setup-node before the action to select the version.
grep -n -B2 -A4 "setup-node" .github/workflows/*.yml2Fix
Add setup-node first, with an explicit version, then run the yarn step.
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: borales/actions-yarn@<release tag from its README>
with:
cmd: install3Verify
The step prints the chosen Node version and yarn install passes.
node --versionConfirmed by github.com
Cause 2 of 3
The version differs from the one the project is built with
1Check
setup-node can read the version from a file, but if node-version is also set, node-version wins.
cat .nvmrc 2>/dev/null
grep -n "node-version" .github/workflows/*.yml2Fix
Keep one source of truth: read the version from the file and drop the hard-coded value.
- uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'3Verify
The job's node --version equals the file.
node --version && cat .nvmrcConfirmed by github.com
Cause 3 of 3
The action is used with a newer Yarn than it supports
1Check
The action's README says it is compatible with Yarn 1.x only.
yarn --version2Fix
For Yarn 2 and later, call yarn from a run step after setup-node instead of using this action.
- uses: actions/setup-node@v4
with:
node-version: '22'
- run: yarn install3Verify
The install step runs with your Node version.
yarn --versionConfirmed by github.com
How do I stop it coming back?
- Always give setup-node an explicit version; never rely on what the runner image has.
- Keep engines in package.json and the CI version in one file.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Back end
npm publish fails in GitHub Actions with ENEEDAUTH
npm error code ENEEDAUTH
ENEEDAUTH means npm has no valid login in the job.
4 causes, each with a fixBack end
npm says it failed to replace ${NPM_TOKEN} in the config
npm error Failed to replace env in config: ${NPM_TOKEN}
npm replaces ${NPM_TOKEN} in .npmrc with the value of an environment variable of that name when it starts.
3 causes, each with a fixBack end
Airflow SSHOperator stops a long script with SSH command timed out
airflow.exceptions.AirflowException: SSH command timed out
SSHOperator waits only 10 seconds for a command by default.
3 causes, each with a fixBack end
Android gets HTML instead of JSON from a PHP API
org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
The response body is not JSON.
2 causes, each with a fixBack end
ng serve says it cannot determine the project or target
Cannot determine project for command.
The Angular CLI looked through angular.json for a project that defines the target you asked for (serve, build, test) and found none, or found several and could not pick one.
3 causes, each with a fixBack end
ng fails with Cannot find module @angular/cli/bin/ng
Cannot find module '@angular/cli/bin/ng'
The ng command is the entry point to the Angular CLI package.
2 causes, each with a fix