4 digit versioning in npm


I’m surprised that 4 digit versioning is not allowed in npm ecosystem:


enter image description here

However, I have to merge my end product from npm to other systems where 4 digits are allowed. So, my question is:

(how) can we somehow make an exception for our own projects to use 4 digits?


You can kind of do it but you need to substitute the last . with a -.
However this is NON-standard and you should probably make sure to comply with npm’s versioning in case you want to upload your project there (I don’t think it can brake anything but it’s still a good to keep the versioning consistent on the plattform.)

Eg. your version would look like 1.1.1-1.

I have seen in it other projects for alpha versions etcs and it allows for non standard version numbers too. Some examples from npm:

  • vue-class-component@8.0.0-rc.1
  • react-docgen@3.0.0-beta7

However be aware that when you use any of the npm version major / minor / patch commands it will not increase that number at first but simply truncate everything starting from the first - character. Example:


npm version patch


npm version patch


I think this is due to the fact that normally people use it to mark a version to be in alpha / beta / rc in that order and when the version is final you keep the version number but remove the suffix.

To automate this you would need to make your own versioning cli that knows how to handle your specific versioning scheme.

Answered By – MarquisBS

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.