npm v6 creating lock files which fail to recreate node_modules

cli
priority:medium
triaged

(Germán Méndez Bravo) #1

I’m opening this issue because:

  • [ ] npm is crashing.
  • [X] npm is producing an incorrect install.
  • [X] npm is doing something I don’t understand.
  • [X] npm is producing incorrect or undesirable behavior.
  • [ ] Other (see below for feature requests):

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:

  • npm -v prints: 6.1.0
  • node -v prints: v10.5.0
  • npm config get registry prints: https://registry.npmjs.org/
  • Windows, OS X/macOS, or Linux?: macOS

(system) #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.