npm install fails "invalid version"

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" : "*" }
}

2 Answers

the version number can only be like \d+\.\d+\.\d+ so \d+\.\d+.\d+.\d+ is not valid. so "1.0.0.0" is not valid and and "1.0.0" is. But check the link below for a more accurat description. This works:

package.json
{ "name": "version-sample", "version": "1.0.0", "dependencies": { "sample" : "*" }
}

The full documentation is located here (including a proper regex

4

"1.0" is not a valid version as defined by Semantic Versioning. Changing it to "1.0.0" should solve your issue.enter image description here

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like