Repository navigation
npm config get cache fails with EBADDEVENGINES when requiring newer npm versions in devEngines #1553
Description
Activity
Hi @patrik-csak ,
Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.Reacted by Patrik Csakv-jitenderpalsingh commented
on May 27, 2026 ContributorMore actionsHello @patrik-csak,
Thank you for the detailed report and for clearly explaining your use case.
The workflow is failing because your project requires npm@^11.10.0 indevEngines.packageManager.version, while the installed npm version is 10.9.7. As a result, npm exits withEBADDEVENGINES,causing the action to fail early.
As a possible workaround, could you try settingonFail: "warn"underdevEngines.packageManager. According to the npm docs, devEngines supports anonFailfield, and setting it to warn should cause the version mismatch to be treated as a warning instead of an error, which may allow the workflow to continue so you can install the required npm version in a later step.Example package.json:
{ "engines": { "node": "^22" }, "devEngines": { "packageManager": { "name": "npm", "version": "^11.10.0", "onFail": "warn" } } }After that, you can install the required npm version in the workflow once setup-node completes successfully.
Also, for additional reference, you can refer to nodejs/node/issues/62425, which is related to npm installation behavior on Node v22.22.2.
Please let us know if the issue persists after trying the above update.Hello @patrik-csak, just a gentle follow-up on this issue. If you have any updates or need further assistance, please let us know.
v-jitenderpalsingh commented
on Jun 15, 2026 ContributorMore actionsHello @patrik-csak, just checking in on this issue. If you have any updates or still need assistance, please let us know.
As a possible workaround, could you try setting
onFail: "warn"underdevEngines.packageManager.I don’t think that’s an acceptable workaround. I think it defeats the purpose of
devEnginesfor this use case.Also, for additional reference, you can refer to nodejs/node/issues/62425, which is related to npm installation behavior on Node v22.22.2.
It’s not clear to me what that issue has to do with this one
For now I’m disabling caching:
steps: - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 with: node-version-file: package.json package-manager-cache: false - shell: bash run: | version="$(jq --raw-output .devEngines.packageManager.version package.json)" npm --global install npm@$version echo "npm: $(npm --version)"
v-jitenderpalsingh commented
on Jun 19, 2026 ContributorMore actionsHello @patrik-csak, Thank you for your feedback.
Yes disabling caching is a possible workaround to prevent the workflow from failing because the caching step internally runsnpm config get cache, which triggers npm'sdevEnginesvalidation against the currently installed npm version, causing theEBADDEVENGINESerror. Also if needed, you can add caching at a later step. You can refer to actions/cache examples for implementation.Example workflow to add caching:
steps: - uses: actions/checkout@v6 - name: Set up Node.js uses: actions/setup-node@v6 with: node-version-file: package.json package-manager-cache: false - name: Upgrade npm run: npm install -g npm@^11.10.0 - name: Get cache dir id: npm-cache-dir run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} - name: Implement cache uses: actions/cache@v5 with: path: ${{ steps.npm-cache-dir.outputs.dir }} key: node-cache-${{ runner.os }}-${{ runner.ARCH }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | node-cache-${{ runner.os }}-${{ runner.ARCH }}-
We will consider this as a feature request and depending on community interest and engagement, we'll explore the possibility of incorporating a fix directly into setup-node.
- addedfeature requestNew feature or request to improve the current logicNew feature or request to improve the current logicand removedbugSomething isn't workingSomething isn't working
on Jun 19, 2026 Thanks, @v-jitenderpalsingh
We hit this issue when working on a bit unconventional monorepo setup. Root of the repository is managed via pnpm, with
devEnginesset properly. But one of the subfolders is still on NPM, has it's own separatepackage.jsonand separate workflow withsetup-nodepointed to it:node-version-file: "subfolder/package.json" cache-dependency-path: "subfolder/package-lock.json"action is able to properly parse and install version of the NodeJS from it, but then
npm config get cacheruns in the root of the repository - where pnpm is used so we getEBADDEVENGINES.
Maybe it would be possible to specify the workdir for the cache config command?Reacted by Mykyta Martsevyiv-jitenderpalsingh commented
on Jul 17, 2026 ContributorMore actionsHello @yafanasiev, Thank you for sharing your use case.
We tried reproducing with the configuration you shared but weren't able to trigger a workflow failure. Could you please provide a link to a failing workflow run or minimal repro link so we can investigate further?In the meantime, you can set
package-manager-cache: falseand use actions/cache separately to handle caching manually.- added a commit that references this issue
on Aug 10, 2026 v-jitenderpalsingh commented
on Sep 17, 2026 ContributorMore actionsHi @yafanasiev, just a gentle follow-up regarding your earlier comment. Are you still experiencing the reported behavior? If so, could you please share a minimal reproduction or a failing workflow run to help us investigate? Thank you.
can you fix this? 👀
ideally you'd just read the
devEngines.packageManagerin this action, realise it is non-default, then install it before dealing with caching.people then also don't need a hand rolled
npm i -g npm@11(or 12).really, this action should just do it based on whats in
devEnginesIMOthis problem leaves people with 2 options:
- Turn off caching, get the right npm version
- Turn off error-level devEngines, get the wrong npm version and lose minAge/allowScripts
neither is ideal obviously. this is a bug rather than a feature i would say
Reacted by Patrik Csak@v-jitenderpalsingh here's a minimal public repro, since you asked for one.
Repro: eran132/runner-images@test/devengines contains only the
package.jsonfrom the original report plus a workflow. Run,ubuntu-24.04, 10 attempts per combination:setup-node caching result v6.4.0 / v7.0.0 default ( package-manager-cache: true)fails 20/20 v6.4.0 / v7.0.0 cache: npmfails 20/20 v6.4.0 / v7.0.0 package-manager-cache: falsesucceeds 20/20 [command]/opt/hostedtoolcache/node/22.23.2/x64/bin/npm config get cache npm error EBADDEVENGINES Invalid semver version "^11.10.0" does not match "10.9.8" for "packageManager" Error: Cache folder paths are not retrieved for npm with cache-dependency-path =Cause:
supportedPackageManagers.npm.getCacheFolderPathinsrc/cache-utils.tsrunsnpm config get cachein the workspace. npm 10.x (the version bundled with Node 22) checksdevEngineseven for this read-only config command and exits 1. It fails before the user gets a chance to upgrade npm in a later step. npm 11.19 (Node 24) doesn't fail here.Possible fix: I tried a few variants in
node:22(npm 10.9.9) andnode:24(npm 11.19.0) containers, 10 runs each, with and without a project.npmrccontainingcache=...:command (run in the project dir) npm 10.9 honours project .npmrccache=npm config get cacheexit 1 – npm config get cache --forceexit 0 (devEngines mismatch printed as warnings) yes npm_config_force=true npm config get cacheexit 0 yes npm config get cache --no-engine-strictexit 1 – same command run from outside the project dir exit 0 no, returns ~/.npmAdding
--forceto that one command seems like the smallest fix that keeps the current semantics, including a project-level.npmrccache override. The same--forcecheck also passed 60/60 on the hosted runner. Running the command from another directory also avoids the error, but it would silently ignore the project's.npmrc.I'm happy to open a PR with this change and a unit test if the approach works for you.
v-jitenderpalsingh commented
on Sep 30, 2026 ContributorMore actionsHello @eran132,
Thank you for providing the reproduction and sharing your detailed findings.
We have confirmed that the issue is reproducible when the installed npm version does not satisfy the requirement in
devEngines.packageManager, causingnpm config get cacheto fail withEBADDEVENGINES.To clarify, we were asking for an example of the monorepo setup with
pnpmat the root andnpmin a subfolder to help us investigate that specific scenario further.We appreciate your help in investigating this issue.
Description: setup-node fails immediately if the initial npm version doesn't satisfy
devEngines.packageManager.versionIf a package requires a specific version of Node.js and a specific version of npm, but the built-in npm version is different than the package's required npm version, setup-node fails immediately (at
npm config get cache) withEBADDEVENGINES, before there is a chance to install a different version of npmFor example, if my package requires Node.js v22.x and npm v11.10+,
npm config get cache failsbecause Node.js v22 ships with npm v10Action version: v6.4.0
Platform:
Runner type:
Tools version:
Repro steps:
Configure
package.json{ "engines": { "node": "^22" }, "devEngines": { "packageManager": { "name": "npm", "version": "^11.10.0" } } }Call setup-node
setup-node fails
Expected behavior:
I expect setup-node to succeed so that I can immediately install a version of npm required by my project
Actual behavior:
setup-node fails before I can install a version of npm required by my project
My use case:
My app requires Node.js v22, so I declare that in
package.json.engines:{ "engines": { "node": "^22" } }I want to enforce
min-release-age, so I add it to.npmrc:min-release-age = 1min-release-agewas added in npm v11.10.0, so I require npm v11.10+ inpackage.json.devEngines:{ "devEngines": { "packageManager": { "name": "npm", "version": "^11.10.0" } } }This is basically the same as #1410, but #1410 was closed with a workaround that only works in certain situations. I created this issue to explain my use case, and my project's constraints, which I think should be pretty standard: require the Maintenance LTS version of Node.js and a newer minimum version of npm
#1410 was closed with this workaround:
This is only possible if your Node.js version is flexible and happens to ship with an npm version that satisfies the project's requirements
Related: #529