npm Community Forum (Archive)

The npm community forum has been discontinued.

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

npm v6 creating lock files which fail to recreate node_modules

I’m opening this issue because:

What’s going wrong?

npm v6 is creating lock files which fail to recreate node_modules after it has been deleted (problem is only in npm v6, in v5 this used to work fine).

I’m getting error 404 when a package uses a subpackage at a certain version but the the sub-package is originally from a folder which is at the requested version.

Apparently, the generated lock file (below) saves the bug-subpackage without a fixed version (a folder instead), and the bug-package.requires cannot resolve the version from the folder:

{
  "name": "bug",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "bug-package": {
      "version": "file:bug-package",
      "requires": {
        "bug-subpackage": "^1.0.0"
      }
    },
    "bug-subpackage": {
      "version": "file:bug-subpackage"
    }
  }
}

npm v5 generated something like:

{
  "name": "bug",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "bug-package": {
      "version": "file:bug-package",
      "requires": {
        "bug-subpackage": "file:bug-subpackage"
      }
    },
    "bug-subpackage": {
      "version": "file:bug-subpackage"
    }
  }
}

How can the CLI team reproduce the problem?

This is a minimal repository which shows the problem:

Inside that repository, do:

  1. npm install
    This creates a package-lock.json and a node_modules fine.

  2. rm -rf node_modules

  3. npm install
    This time it will use the package-lock.json, and it will fail with the following error:

npm ERR! code E404
npm ERR! 404 Not Found: bug-subpackage@^1.0.0

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kronuz/.npm/_logs/2018-07-02T19_18_57_203Z-debug.log

supporting information:


Triage note: Looks like another regression related to the requires field changes.