npm: Why is a version “0.1” invalid?

前端 未结 3 1176
予麋鹿
予麋鹿 2020-12-04 17:20

I had to change the version of my npm app from 0.1 to 0.0.1 in order for npm not to do this.

$ npm install
npm ERR! install Couldn\'t read dependencies
npm          


        
相关标签:
3条回答
  • 2020-12-04 17:52

    Simple answer - use 0.1.0

    0.1 will not work

    Happy coding!

    0 讨论(0)
  • 2020-12-04 17:54

    So yea, the short answer is "You need to use semantic versioning"

    But the reasoning behind that is to provide a sensible, uniform package version to all users of npm. When getting a version number of an package, you have some level of confidence that the author understands semver and is employing it properly.

    0 讨论(0)
  • 2020-12-04 18:00

    Yes, this is required for semantic versioning, which is the versioning scheme npm packages use. Here's the snippet from npm help json:

    Version must be parseable by node-semver, which is bundled with npm as a dependency. (npm install semver to use it yourself.)

    Here's how npm's semver implementation deviates from what's on semver.org:

    • Versions can start with "v"
    • A numeric item separated from the main three-number version by a hyphen will be interpreted as a "build" number, and will increase the version. But, if the tag is not a number separated by a hyphen, then it's treated as a pre-release tag, and is less than the version without a tag. So, 0.1.2-7 > 0.1.2-7-beta > 0.1.2-6 > 0.1.2 > 0.1.2beta
    0 讨论(0)
提交回复
热议问题