npm refuses to generate package-lock.json

170 views Asked by At

If I update a dependency manually in the package.json or "automatically" (by installing a package through npm CLI) both methods do not update the package-lock.json leaving me with a broken npm ci build (inconsistencies between package.json and package-lock.json not allowed).

  • NPM version 10.2.3
  • Ubuntu 22.04.3 LTS
  • We are working on an Angular/TypeScript project.

Things I have tried without a package-lock.json being updated (or created for that matter):

  • npm install --save-dev webpack
  • manually set the dependency in my package.json and run npm install
  • try other commands such as ng build <project> --configuration <any-env> or npm i or npm audit fix etc.
  • repeat any of the above commands with or without npm_modules and/or dist folder removed

My colleague, on macOS, does see updates of the package-lock.json file with npm install after manually changing a dependency in the package.json and I cannot figure out why.

I have read and tried solutions in the following topics without resolving:

2

There are 2 answers

0
MarcelTon On BEST ANSWER

TLDR: well this is embarrassing; don't have a package-lock=false in your .npmrc. The end.

1
Harsh Vaidya On

Open the terminal as admin Follow the following lines: 1)npm cache clean --force 2)npm config list 3)npm ci 4)rm -rf node_modules rm -f package-lock.json 5) npm install --save-dev webpack 6)npm install -g npm@latest This will solve your error