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 [email protected] does not satisfy [email protected]
npm error Missing: [email protected] from lock file
npm error Missing: [email protected] from lock file
npm error Invalid: lock file's [email protected] does not satisfy [email protected]
npm error Missing: [email protected] from lock file
npm error Missing: [email protected] 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 [email protected] does not satisfy [email protected]
npm error Missing: [email protected] from lock file
npm error Missing: [email protected] from lock file
npm error Invalid: lock file's [email protected] does not satisfy [email protected]
npm error Missing: [email protected] from lock file
npm error Missing: [email protected] from lock file

<snip>

# npm ls chokidar
PROJECT@ /Users/USER/_code/path
├─┬ @angular/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ @angular/[email protected]
│ └─┬ @angular-devkit/[email protected]
│   └── [email protected] deduped invalid: "^3.5.2" from node_modules/@angular-devkit/core
├─┬ @angular/[email protected]
│ └── [email protected] invalid: "^3.5.2" from node_modules/@angular-devkit/core
├─┬ @cust/[email protected]
│ └─┬ [email protected]
│   └─┬ @angular-devkit/[email protected]
│     └─┬ @angular-devkit/[email protected]
│       └── [email protected]
└─┬ [email protected]
  └─┬ @angular-devkit/[email protected]
    └─┬ [email protected]
      └── [email protected]

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/[email protected]
│ └─┬ [email protected]
│   └── [email protected]
├─┬ @angular/[email protected]
│ └─┬ @angular-devkit/[email protected]
│   └── [email protected] deduped
├─┬ @angular/[email protected]
│ └── [email protected]
├─┬ @cust/[email protected]
│ └─┬ [email protected]
│   └─┬ @angular-devkit/[email protected]
│     └─┬ @angular-devkit/[email protected]
│       └── [email protected] deduped
└─┬ [email protected]
  └─┬ @angular-devkit/[email protected]
    └─┬ [email protected]
      └── [email protected] 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