Npm Install Fails "Invalid Version"

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.

1

Your Answer

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

Sophia Al-Mansoor
Author

Sophia Al-Mansoor

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.