[BUG] semver.lt returns wrong value for pre-release version comparison

Aperta
#483 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@Doomguy-BFG9000 ci sta già lavorando.

Dal 6/11/2026.

  • #947 di @Doomguy-BFG9000 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, node.js
Ambito
tooling

Direzione di ricerca

Start by reproducing the reported semver.lt('0.2.0-1', '0.2.0', { includePrerelease: false }) result in a Node shell, then inspect the semver.lt comparison entry point and prerelease handling. Done means the comparison returns false for this input and existing comparison behavior remains covered by tests.

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

Descrizione

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

Using semver.lt() returns the incorrect value when comparing pre-release version with includePrerelease set to false (or the default).

image

By comparison, explicitly coercing you get:

semver_1.lt(semver_1.coerce('0.2.0-1'), minVersion)
false

My assumption is that strings are implicitly coerced when calling comparison functions, perhaps this is incorrect?

Expected Behavior

semver.lt('0.2.0-1', '0.2.0', { includePrerelease: false }) should return false.

Steps To Reproduce
  1. In node shell
  2. With the current latest version of semver installed
  3. Run 'require('semver').lt('0.2.0-1', '0.2.0', { includePrerelease: false })
  4. Wrong value true is returned
Environment
  • npm: 6.14.15
  • Node: 14.8.1
  • OS: Mac Monterey 12.5.1
  • platform: Macbook Pro i9
Lingua principale
JavaScript
Stelle
5.5k
Fork
635
Merge medio
1h 24m
PR unite (30g)
6

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.