npm / rfcs

Public change requests/proposals & ideation
Other
726 stars 238 forks source link

[RRFC] Default `npm install` to using x.x.x version incrementing scheme instead of `*`/`^`/`~` #692

Closed bronzehedwick closed 1 year ago

bronzehedwick commented 1 year ago

Motivation ("The Why")

Prepending the version number with *, ^, or ~ is more confusing than replacing the semver version places with an x. The three symbols have no inherent meaning with the version place they allow to be bumped, while placing an x clearly indicates that that place is variable.

An extra layer of confusion with prepending symbols comes from writing a literal number in the version string after it. That exact version number is likely not the version currently installed, decreasing readability.

Example

Reading the version ^1.12.14 I have to remember:

  1. That ^ corresponds to bumping the minor version
  2. That 1.12.14 does not represent the version of the package installed, only the version of the package the last time the version incrementing scheme was changed

How

Current Behaviour

Running npm install uses the symbol prepending version incrementing scheme.

Desired Behaviour

Running npm install uses the x variable placeholder version incrementing scheme.

References

ljharb commented 1 year ago

There's critical information in that, though - 1.12.x allows 1.12.13, and ^1.12.14 means the package will break unless it's at least 1.12.14.

The ^ is the best choice. The version of the package installed can never be inferred from looking at package.json anyways, you have to look at the lockfile or node_modules.

ljharb commented 1 year ago

Also, ^ does NOT correspond to bumping the minor version - you could bump patch and/or minor, or it could be the exact version listed.

bronzehedwick commented 1 year ago

There's critical information in that, though - 1.12.x allows 1.12.13, and ^1.12.14 means the package will break unless it's at least 1.12.14.

Also, ^ does NOT correspond to bumping the minor version - you could bump patch and/or minor, or it could be the exact version listed.

Ah I did not know that, thank you for explaining! While I still think the x is more readable, the difference in meaning makes it a no-go.