Skip to content

[BUG] Need to run npm install twice to fix npm ci command #7793

@Saibamen

Description

@Saibamen

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

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

Expected Behavior

npm ci should install packages without exception

Steps To Reproduce

Download repro repository: https://github.com/Saibamen/npm-double-install-bug

  1. Delete package-lock.json
  2. npm install
  3. npm ci

See errors

Building with commited lock file (created on Windows) and npm ci:

Check NPM

Building with fresh lock file, npm install and then npm ci

Check NPM with new lock file

Annoying workarounds

Workaround v1

Check NPM with workaround

  1. npm install
  2. Delete node_modules
  3. npm install
  4. npm ci

Workaround v2

Just run npm install twice, no need to delete node_modules.

Check NPM with workaround v2

  1. npm install
  2. npm install
  3. npm ci

Environment

  • npm: 10.8.3
  • Node.js: 20.17.0
  • OS Name: Windows 10
  • System Model Name: 10.0.19045.4894
  • npm config:
; node bin location = C:\Program Files\nodejs\node.exe
; node version = v20.17.0
; npm local prefix = C:\XXX\npm-double-install-bug
; npm version = 10.8.3
; cwd = C:\XXX\npm-double-install-bug
; HOME = C:\Users\YYY
; Run `npm config ls -l` to show all defaults.

Diff after running npm install second time:

diff --git a/package-lock.json b/package-lock.json
index 07842ff..4823f0c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1606,6 +1606,16 @@
         }
       }
     },
+    "node_modules/eslint-plugin-svelte/node_modules/yaml": {
+      "version": "1.10.2",
+      "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
+      "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
+      "dev": true,
+      "license": "ISC",
+      "engines": {
+        "node": ">= 6"
+      }
+    },
     "node_modules/eslint-scope": {
       "version": "7.2.2",
       "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz",
@@ -3528,21 +3538,6 @@
         }
       }
     },
-    "node_modules/svelte-check/node_modules/yaml": {
-      "version": "2.5.1",
-      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz",
-      "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==",
-      "dev": true,
-      "license": "ISC",
-      "optional": true,
-      "peer": true,
-      "bin": {
-        "yaml": "bin.mjs"
-      },
-      "engines": {
-        "node": ">= 14"
-      }
-    },
     "node_modules/svelte-eslint-parser": {
       "version": "0.41.1",
       "resolved": "https://registry.npmjs.org/svelte-eslint-parser/-/svelte-eslint-parser-0.41.1.tgz",
@@ -3737,19 +3732,6 @@
         "url": "https://github.com/sponsors/antonk52"
       }
     },
-    "node_modules/tailwindcss/node_modules/yaml": {
-      "version": "2.5.1",
-      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz",
-      "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==",
-      "dev": true,
-      "license": "ISC",
-      "bin": {
-        "yaml": "bin.mjs"
-      },
-      "engines": {
-        "node": ">= 14"
-      }
-    },
     "node_modules/text-table": {
       "version": "0.2.0",
       "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@@ -4067,13 +4049,16 @@
       "license": "ISC"
     },
     "node_modules/yaml": {
-      "version": "1.10.2",
-      "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz",
-      "integrity": "sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg==",
+      "version": "2.5.1",
+      "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz",
+      "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==",
       "dev": true,
       "license": "ISC",
+      "bin": {
+        "yaml": "bin.mjs"
+      },
       "engines": {
-        "node": ">= 6"
+        "node": ">= 14"
       }
     },
     "node_modules/yocto-queue": {

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