npm: Why is a version "0.1" invalid?

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.


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

Simple answer - use 0.1.0

0.1 will not work

Happy coding!

Tags:

Node.Js

Npm