When trying to install from the package.json, following error occurs
>npm install npm ERR! install Couldn't read dependencies npm ERR! Error: Invalid version: "1.0.0.0"
package.json
{
"name": "version-sample",
"version": "1.0.0.0",
"dependencies": {
"sample" : "*"
}
}
TLDR; Semantic Versioning (semver) is enforced.
To answer the question:
The version number can only be like \d+\.\d+\.\d+
, so \d+\.\d+.\d+.\d+
is not valid. Therefore "1.0.0.0" is not valid and and "1.0.0" is. But check the link below for a more accurat description.
Here’s an example of a valid package.json
:
{
"name": "version-sample",
"version": "1.0.0",
"dependencies": {
"sample" : "*"
}
}
NPM has some documentation. The full documentation of Semantic Versionenig (semver) can be found here https://semver.org/ (including a proper regex)
Short excursion about valid versions:
And this is how the version should be created:
Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes
MINOR version when you add functionality in a backwards compatible manner
PATCH version when you make backwards compatible bug fixes
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
Here are some sample of semver valid versions: