Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

`npm config get cache` fails with `EBADDEVENGINES` when requiring newer npm versions in `devEngines`

Aperta
#1,553 14 commenti 2 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
ci-cd, devops, tooling

Direzione di ricerca

Inizia tracciando il percorso della cache del package manager di setup-node e l'invocazione npm config get cache rispetto alla configurazione devEngines di package.json segnalata. Riproduci il problema con Node.js 22 e npm 10, quindi verifica che setup-node venga completato e consenta l'installazione della versione richiesta di npm prima di configurare la cache.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

feature request

Description: setup-node fails immediately if the initial npm version doesn't satisfy devEngines.packageManager.version

If 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) with EBADDEVENGINES, before there is a chance to install a different version of npm

For example, if my package requires Node.js v22.x and npm v11.10+, npm config get cache fails because Node.js v22 ships with npm v10

Action version: v6.4.0

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

  • Node.js: 22.22.2
  • npm: 10.9.7

Repro steps:

  1. Configure package.json

    {
    	"engines": {
    		"node": "^22"
    	},
    	"devEngines": {
    		"packageManager": {
    			"name": "npm",
    			"version": "^11.10.0"
    		}
    	}
    }
    
  2. Call setup-node

    jobs:
      setup-node:
        runs-on: 'ubuntu-latest'
        steps:
          - uses: actions/[email protected]
    
          # fails
          - uses: actions/[email protected]
            with:
              node-version-file: package.json
    
          # never runs
          - run: npm --global install npm@^11.10.0
    
  3. setup-node fails

    Run actions/[email protected]
    with:
      node-version-file: package.json
      check-latest: false
      token: ***
      package-manager-cache: true
    
    Resolved package.json as ^22
    Found in cache @ /opt/hostedtoolcache/node/22.22.2/x64
    
    Environment details
    node: v22.22.2
    npm: 10.9.7
    yarn: 1.22.22
    
    Detected npm as the package manager from package.json's packageManager field. Auto caching has been enabled for npm. If you want to disable it, set package-manager-cache input to false
    /opt/hostedtoolcache/node/22.22.2/x64/bin/npm config get cache
    npm error code EBADDEVENGINES
    npm error EBADDEVENGINES The developer of this package has specified the following through devEngines
    npm error EBADDEVENGINES Invalid devEngines.packageManager
    npm error EBADDEVENGINES Invalid semver version "^11.10.0" does not match "10.9.7" for "packageManager"
    npm error EBADDEVENGINES {
    npm error EBADDEVENGINES   current: { name: 'npm', version: '10.9.7' },
    npm error EBADDEVENGINES   required: { name: 'npm', version: '^11.10.0' }
    npm error EBADDEVENGINES }
    

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 = 1

min-release-age was added in npm v11.10.0, so I require npm v11.10+ in package.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:

The reliable workaround is to specify a Node version in setup-node that already includes the npm version your devEngines.packageManager requires. This ensures the npm version matches your project’s requirements from the start.

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

Lingua principale
TypeScript
Stelle
5k
Fork
1.7k
Merge medio
4g 22h
PR unite (30g)
5

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di actions/setup-node

Tutte le issue di actions/setup-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.