Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix "npm ERR! Errors were found in your package-lock.json"

Tags:

npm

I am getting the follow error in npm. what does this mean please and how may I fix this error?

npm ERR! code ELOCKVERIFY
npm ERR! Errors were found in your package-lock.json, run  npm install  to fix them.
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/animations@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/common@~12.1.0-   
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/compiler@~12.1.0-    
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/core@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/forms@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/platform-browser@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/platform-browser-dynamic@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/router@~12.1.0-
npm ERR!     Invalid: lock file's @angular/[email protected] does not satisfy @angular/compiler-cli@~12.1.0-
like image 449
labi Avatar asked Jul 14 '26 03:07

labi


2 Answers

I know that sometimes the previous solutions don't always work, which does seem to be the case with the latest release of Angular's CLI.

Here are the steps I used to fix my issue:

  1. Remove package-lock.json rm package-lock.json
  2. Under the dependencies & devDependencies sections in your package.json update any version number that looks like ~12.1.0-
  3. Then run npm install

Hope this helps you solve the issue you are having.

Have a good one :)

Matthew

like image 173
Matthew van der Westhuizen Avatar answered Jul 15 '26 16:07

Matthew van der Westhuizen


Unfortunately deleting package-lock.json and running npm install won't work in this instance. I had the exact same error after running ng new. After reviewing npm versioning and scratching my head for bit, I did the following (which fixed it):

  1. Deleted package-lock.json
  2. Deleted node_modules
  3. Ran npm cache clean --force
  4. Edited package.json for each of the referenced libraries and changed the "0-" to "3" (e.g. "@angular/animations": "~12.1.3" instead of "@angular/animations": "~12.1.0-")

I don't know if all of the steps were completely necessary, but whenever I start running into any npm weirdness that doesn't have an obvious fix, I always do steps 1 thru 3.

As for the meaning of the error message, each line is indicating that the version of the library which has been installed fails to fall within the range of versions you have indicated (within your package.json) you will accept.

The mystery to me is how/why version 12.1.3 of anything would be installed if my package.json indicated 12.1.0. The trailing "-" clearly has something to do with it, but I didn't see anything about it being part of the npm versioning syntax (linked above). And while the Semantic Versioning Spec does indeed allow for hyphens for indicating a pre-release version, it MUST be trailed by something.

like image 44
JAWeber Avatar answered Jul 15 '26 16:07

JAWeber