Skip to content

[BUG] npm dedupe step fails, a additional "npm i" run fixes the issue #7847

@neophob

Description

@neophob

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

  • run npm i on a clean project (no package-lock.json file, no node_modules directory)
  • npm should generate a package-lock.json file that can be used with npm ci
  • in my case this is not the case as there is an issue with a deduped version
# rm -rf ./node_modules
# rm package-lock.json 
# npm i

added 1930 packages, and audited 1931 packages in 3m

<snip>

# npm ci
npm error code EUSAGE
npm error
npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm error
npm error Invalid: lock file's chokidar@4.0.1 does not satisfy chokidar@3.6.0
npm error Missing: chokidar@4.0.1 from lock file
npm error Missing: glob-parent@5.1.2 from lock file
npm error Invalid: lock file's readdirp@4.0.2 does not satisfy readdirp@3.6.0
npm error Missing: picomatch@2.3.1 from lock file
npm error Missing: readdirp@4.0.2 from lock file
npm error code EUSAGE
npm error
npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm error
npm error Invalid: lock file's chokidar@4.0.1 does not satisfy chokidar@3.6.0
npm error Missing: chokidar@4.0.1 from lock file
npm error Missing: glob-parent@5.1.2 from lock file
npm error Invalid: lock file's readdirp@4.0.2 does not satisfy readdirp@3.6.0
npm error Missing: picomatch@2.3.1 from lock file
npm error Missing: readdirp@4.0.2 from lock file

<snip>

# npm ls chokidar
PROJECT@ /Users/USER/_code/path
├─┬ @angular/build@18.2.9
│ └─┬ sass@1.77.6
│   └── chokidar@3.6.0
├─┬ @angular/cli@18.2.9
│ └─┬ @angular-devkit/core@18.2.9
│   └── chokidar@4.0.1 deduped invalid: "^3.5.2" from node_modules/@angular-devkit/core
├─┬ @angular/compiler-cli@18.2.8
│ └── chokidar@4.0.1 invalid: "^3.5.2" from node_modules/@angular-devkit/core
├─┬ @cust/eslint-plugin@2.14.0
│ └─┬ eslint-plugin-ngrx@2.1.4
│   └─┬ @angular-devkit/schematics@13.3.11
│     └─┬ @angular-devkit/core@13.3.11
│       └── chokidar@3.6.0
└─┬ jest-preset-angular@14.2.4
  └─┬ @angular-devkit/build-angular@18.2.9
    └─┬ webpack-dev-server@5.0.4
      └── chokidar@3.6.0

Now if I run npm i again, this will fix the issue:

# npm i 

added 4 packages, removed 12 packages, changed 2 packages, and audited 1923 packages in 3s

# npm ls chokidar
PROJECT@ /Users/USER/_code/path
├─┬ @angular/build@18.2.9
│ └─┬ sass@1.77.6
│   └── chokidar@3.6.0
├─┬ @angular/cli@18.2.9
│ └─┬ @angular-devkit/core@18.2.9
│   └── chokidar@3.6.0 deduped
├─┬ @angular/compiler-cli@18.2.8
│ └── chokidar@4.0.1
├─┬ @cust/eslint-plugin@2.14.0
│ └─┬ eslint-plugin-ngrx@2.1.4
│   └─┬ @angular-devkit/schematics@13.3.11
│     └─┬ @angular-devkit/core@13.3.11
│       └── chokidar@3.6.0 deduped
└─┬ jest-preset-angular@14.2.4
  └─┬ @angular-devkit/build-angular@18.2.9
    └─┬ webpack-dev-server@5.0.4
      └── chokidar@3.6.0 deduped


Expected Behavior

npm i builds a proper lock file in the first run ;)

Steps To Reproduce

  • see package.json in the first comment below
  • run npm i then npm ci to see the error

Environment

  • npm: 10.8.2
  • Node.js: 20.18.0
  • OS Name: OSX
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingDuplicateduplicate of another, existing issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions