镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Adopt Semantic Versioning 2.0.0: returning X.Y.Z instead of vX.Y.Z for node -v #40964

Description

@pubmikeb

Is your feature request related to a problem? Please describe.
Following https://github.com/nodejs/node/discussions/40957, Node.js version format contains a v-prefix prior the version, e.g. node -v returns v17.1.0. According to the https://semver.org/#is-v123-a-semantic-version, v17.1.0 is not semver compliant.

Describe the solution you'd like
Drop v from the version number and return 17.1.0 for node -v.

It should not be a problem at all if implemented in a major version:

MAJOR version when you make incompatible API changes

Besides, if a Node.js version check implemented properly, not just substringing the first char, it should not break anything.

Activity

  1. changed the title [-]Adopt Semantic Versioning 2.0.0: return `17.1.0` for `node -v`[/-] [+]Adopt Semantic Versioning 2.0.0: returning `X.Y.Z` instead of `vX.Y.Z` for `node -v`[/+] on Nov 25, 2021
  2. Trott commented on Nov 25, 2021

    @Trott
    Member

    In case it helps with your use case, if you want the version without a v, you can use process.versions.node.

    $ node -p process.versions.node
    17.1.0
    $

    It should not be a problem at all if implemented in a major version:

    True if you maintain libraries used by a few thousand people. Not even close to true for Node.js.

    This seems like a change that is guaranteed to break a lot of code for little or no upside.

  3. pubmikeb commented on Nov 25, 2021

    @pubmikeb
    Author

    This seems like a change that is guaranteed to break a lot of code for little or no upside.

    No one should update a major version without checking release notes, especially the section "Breaking changes". So, if such change would not be digged somewhere in a list of commits, then there should not be a problem.

    For instance, the 17.1.0 release introduced an asert for importing JSON modules, which broke the native importing of JSONs, although assert is not at the stage 4 of TC39 and therefore is not supported by ESLint:

    import appConfig from "./appconfig.json" assert {type: "json"};

    That was even not a major release, just a minor one but still broke a code, which used to work for several years (yes, I know it's under the flag, but still).

  4. aduh95 commented on Nov 25, 2021

    @aduh95
    Contributor

    17.1.0 release introduced an assert for importing JSON modules, which broke the native importing of JSONs

    Anything experimental is explicitly opted-out from semver:

    > Stability: 1 - Experimental. The feature is not subject to
    > [Semantic Versioning][] rules. Non-backward compatible changes or removal may
    > occur in any future release. Use of the feature is not recommended in
    > production environments.

    That's why importing a JSON module comes with a ExperimentalWarning: Importing JSON modules is an experimental feature. This feature could change at any time warning. FYI you can still use assertionless JSON imports if you are willing to use an extra flag, see #40758 (comment).

    No one should update a major version without checking release notes

    Reading the release notes would not help you in case you are relying on an old version of a package or software that do expect to see a v at the start of the output of node -v. Sure you can say it's on them, and they should either upgrade the other software, or keep using the old Node.js version, but to me that sounds like making the life of some of our users harder for the sake of correctness.

  5. targos commented on Nov 25, 2021

    @targos
    Member

    FWIW, I checked the output of --version for other software (git, deno, zsh, gh) and none of them output a semver-compatible string.

  6. pubmikeb commented on Nov 25, 2021

    @pubmikeb
    Author

    FWIW, I checked the output of --version for other software (git, deno, zsh, gh) and none of them output a semver-compatible string.

    I've just checked a value for git --version and got:

    git version 2.34.1.windows.1
    

    Well, if other significant projects aren't semver-compatible as well, then OK, although, it's always good to be a widely accepted standard compatible.

  7. Trott commented on Nov 26, 2021

    @Trott
    Member

    Thanks for opening the issue. I'm going to close this. If any collaborators think we should reconsider, please comment or reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues requesting new Node.js features.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions