npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm install only partial if versioning isn't semantic

Hi all,


I was unable to install many packages by running npm install with this package.json file:

    "name": "something",
    "description": "something",
    "author": {
        "name": "JD",
        "email": ""
    "version": "0.1",
    "keywords": [
    "repository": {
        "type": "git",
        "url": ""
    "dependencies": {
        "clean-webpack-plugin": "^3.0.0",
        "css-loader": "^3.1.0",
        "mini-css-extract-plugin": "^0.8.0",
        "node-sass": "^4.12.0",
        "package.json": "^2.0.1",
        "sass-loader": "^7.1.0",
        "stylelint": "^10.1.0",
        "ts-loader": "^6.0.4",
        "typescript": "^3.5.3",
        "webpack": "^4.36.1",
        "eslint": "^6.1.0",
        "webpack-cli": "^3.3.6"

There are warnings, including an incorrect version without additional details.

After many trials and errors, changing the version to 1.0.0 solves the issue.

Can you fix this?

Yeah, the version field has to be a valid SemVer version if it exists.

$ npm i
npm WARN Invalid version: "0.1"

The error message could probably be improved. What would have helped you?

Of course, we could probably also just ignore the version field in the top-level package, since it’s probably an app you aren’t publishing anyway, but a lot of things are simpler if npm can just assume that every version in ever package.json file follows the same spec.

Oddly, that is what we do if the version is missing entirely. Probably it’d be better to treat an invalid version the same as a missing version. And, in both cases, warn but proceed with the operation.

To me, if the version is optional, it shouldn’t crash and since there is a dependency tree, it would help to know on which package the issue is occurring. For instance:

The version on package $(package_name) is invalid and should follow semantic versioning. E.g: 1.2.3, 1.2.3-BETA.