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

[BUG] minVersion returns 0.0.0 when a 0.0.0 prerelease is the true minimum

Aperta Adatta ai principianti
#934 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@thisisshivamtiwari ci sta già lavorando.

Dal 29/10/2026.

  • #936 di @thisisshivamtiwari — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend

Direzione di ricerca

Inizia dalla scorciatoia indicata nell’issue in ranges/min-version.js, quindi esamina i test correlati a minVersion e il confronto tra le versioni prerelease e 0.0.0. Riproduci gli esempi dell’issue e verifica che il minimo per >=0.0.0-alpha <1.0.0 e * con includePrerelease venga restituito correttamente. Il lavoro è concluso quando questi casi passano senza modificare il comportamento documentato relativo alla versione più bassa.

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

Descrizione

Bug Needs Triage
Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

This is admittedly a bit pedantic, but minVersion seems to treat 0.0.0 as a special case. A prerelease lower bound is respected on every tuple except 0.0.0:

semver.minVersion('>=1.0.0-alpha <2.0.0').version // '1.0.0-alpha'
semver.minVersion('>=0.0.1-alpha <1.0.0').version // '0.0.1-alpha'
semver.minVersion('>=0.0.0-alpha <1.0.0').version // '0.0.0'

The same thing happens with includePrerelease, where 0.0.0-0 satisfies * but 0.0.0 is returned:

semver.minVersion('*', { includePrerelease: true }).version // '0.0.0'

This comes from the shortcut at the top of ranges/min-version.js, which tries 0.0.0 before 0.0.0-0 and returns the first one that matches.

Expected Behavior

I'd expect '0.0.0-alpha' and '0.0.0-0' respectively, since the README describes minVersion as returning "the lowest version that can match the given range", and the rest of the library agrees that these sort below 0.0.0 (lt, sort, minSatisfying).

I couldn't find anything (docs, tests, or the original PR npm/node-semver#241) suggesting 0.0.0 is meant to be special here, so I suspect the shortcut just wasn't written with prerelease lower bounds in mind. But if this is intentional it might be worth documenting.

Steps To Reproduce
  1. npm install [email protected]
  2. Run node -e "console.log(require('semver').minVersion('>=0.0.0-alpha <1.0.0').version)"
  3. See 0.0.0
Environment
  • npm: 11.20.0
  • Node: 26.12.1
  • OS: macOS 26.6.1
  • platform: Apple Silicon (arm64)
  • semver: 7.8.5 (same code on main)

AI disclosure: this issue was discovered with AI assistance

Lingua principale
JavaScript
Stelle
5.5k
Fork
622
Merge medio
4g 23h
PR unite (30g)
4

Preparare l'ambiente

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 npm/node-semver

Tutte le issue di npm/node-semver

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.