How to fix "npm ERR! Errors were found in your package-lock.json" - 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/animations#12.1.3 does not satisfy #angular/animations#~12.1.0-
npm ERR! Invalid: lock file's #angular/common#12.1.3 does not satisfy #angular/common#~12.1.0-
npm ERR! Invalid: lock file's #angular/compiler#12.1.3 does not satisfy #angular/compiler#~12.1.0-
npm ERR! Invalid: lock file's #angular/core#12.1.3 does not satisfy #angular/core#~12.1.0-
npm ERR! Invalid: lock file's #angular/forms#12.1.3 does not satisfy #angular/forms#~12.1.0-
npm ERR! Invalid: lock file's #angular/platform-browser#12.1.3 does not satisfy #angular/platform-browser#~12.1.0-
npm ERR! Invalid: lock file's #angular/platform-browser-dynamic#12.1.3 does not satisfy #angular/platform-browser-dynamic#~12.1.0-
npm ERR! Invalid: lock file's #angular/router#12.1.3 does not satisfy #angular/router#~12.1.0-
npm ERR! Invalid: lock file's #angular/compiler-cli#12.1.3 does not satisfy #angular/compiler-cli#~12.1.0-

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:
Remove package-lock.json rm package-lock.json
Under the dependencies & devDependencies sections in your package.json update any version number that looks like ~12.1.0-
Then run npm install
Hope this helps you solve the issue you are having.
Have a good one :)
Matthew

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):
Deleted package-lock.json
Deleted node_modules
Ran npm cache clean --force
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.

rm package-lock.json
npm install

Remove the trailing - from package.json for all the packages mentioned in the error message.

Related

Modifying an npm package locally to manually fix dependency tree issues?

In the process of learning nest.js, I've run into an npm dependency tree issue.
I'm attempting to do something like npm install --save-dev #types/bcrypt #types/passport #types/passport-jwt. This (and similar npm commands) will throw this error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #nestjs/passport#8.2.1
npm ERR! Found: passport#0.6.0
npm ERR! node_modules/passport
npm ERR! passport#"^0.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer passport#"^0.4.0 || ^0.5.0" from #nestjs/passport#8.2.1
npm ERR! node_modules/#nestjs/passport
npm ERR! #nestjs/passport#"^8.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: passport#0.5.3
npm ERR! node_modules/passport
npm ERR! peer passport#"^0.4.0 || ^0.5.0" from #nestjs/passport#8.2.1
npm ERR! node_modules/#nestjs/passport
npm ERR! #nestjs/passport#"^8.2.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
I've traced the problem to the following:
I currently have version 8.2.1 of #nestjs/passport installed - this was released on Feb 16
I can see in my local folder of node_modules/#nestjs/passport/package.json that it has the dependency "passport": "^0.4.0 || ^0.5.0 , as the terminal error implies
In the current Github version of #nestjs/passport, however, I see that they've updated that line to include || ^0.6.0 in late May link
#nestjs/passport hasn't created a new release with this (and other) updates yet though.
Two things I'm wondering:
How can I resolve this dependency issue now, before the maintainers of #nestjs/passport publish their next release?
Why doesn't it work for me to go into my local node_modules/#nestjs/passport/package.json file and manually change it to include ^0.6.0? (After doing that, saving the file, and trying the npm commands again, I still get the same dependency errors)
NPM has already answered the question for you, there are two solution you can try, either run :
npm install --legacy-peer-deps
This section from the npm blog explains what that command does:
We have identified automatic peerDependencies installation as a potentially disruptive change for many users (albeit one that we are confident is the correct behavior for a package manager), we have some tools to minimize this disruption, based on the feedback we get.
We are confident that resolving package trees such that peerDependencies are properly accounted for is the right thing to do. After all, an error here can result in a production issue that’s very difficult to debug later, especially if it occurs deep in a node_modules tree. However, years of not resolving peerDependencies has allowed many projects to fail to notice these problems.
In order to get unblocked and install your project in spite of peerDependencies conflicts, you can use the --legacy-peer-deps flag at install time. It may be that the disruption is too great to take all at once, and we have to have this flag enabled by default for a while as projects gradually update their conflicting dependencies. Our intent is to let the beta give us some more data points to help make that decision carefully.
Or force passport into installing (I'm not sure that is recommended)
npm install [package] --force
This will force npm to fetch remote resources even if a local copy exists on disk.
Good Luck.

I cannot install npm with node, any ideas? [duplicate]

I keep getting the same error message when trying to create a new angular project.
I tried to create a new angular project using Windows Powershell with the following commands:
ng new hello-world
-> Would you like to add angular routing? - Yes
-> Stylesheet format? - CSS
I obtained the error message below. I already tried to reinstall angular cli and I'm running Powershell using Administrator.
Installed versions:
Angular CLI: 8.0.6
Node: 10.16.0
OS: win32 x64
Error message:
npm WARN tarball data for tslint#~5.15.0 (sha512-6bIEujKR21/3nyeoX2uBnE8s+tMXCQXhqMmaIPJpHmXJoBJPTLcI7/VHRtUwMhnLVdwLqqY3zmd8Dxqa5CVdJA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for jasmine-spec-reporter#~4.2.1 (sha512-FZBoZu7VE5nR7Nilzy+Np8KuVIOxF4oXDPDknehCYBDE080EnlPu0afdZNmpGDBRCUBv3mj5qgqCRmk6W/K8vg==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for acorn#^6.0.5 (sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==) seems to be corrupted. Trying one more time.
npm WARN tarball tarball data for #angular/language-service#~8.0.3 (sha512-04XojOo9FJgEQE/rZafnaJQxPEU+//TSzTgpGoIVzCSMx+joCY/ZSSwJZPWxiHlOE57W/zX02ZY+TwcM81oTdw==) seems to be corrupted. Trying one more time.
npm WARN tar ENOENT: no such file or directory, open 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\#angular\platform-browser-447d0944\esm2015\animations\src\animation_builder.js'
npm ERR! path C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR! { [Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\jasmine-spec-reporter-cbb15ffc\screenshot.gif'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif' },
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink \'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'C:\\Users\\konta\\Desktop\\Programming_files\\Angular\\hello-world\\node_modules\\.staging\\jasmine-spec-reporter-cbb15ffc\\screenshot.gif',
npm ERR! parent: 'hello-world' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm WARN tar EPERM: operation not permitted, lstat 'C:\Users\konta\Desktop\Programming_files\Angular\hello-world\node_modules\.staging\#angular\router-8388bfd5\esm2015\src\directives'
npm WARN tarball tarball data for typescript#3.4.4 (sha512-xt5RsIRCEaf6+j9AyOBgvVuAec0i92rgCaS3S+UVf5Z/vF2Hvtsw08wtUTJqp4djwznoAgjSxeCcU4r+CcDBJA==) seems to be corrupted. Trying one more time.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\konta\AppData\Roaming\npm-cache\_logs\2019-07-01T01_21_13_653Z-debug.log
Package install failed, see above.
I found the problem: My antivirus was somehow blocking the files without me knowing. It worked once I paused my antivirus during the installation.
In windows10 I disabled the windows defender / windows security ==> realtime protection and try again npm install command and it worked
1.
2.
3.
NOTE : Turn on the real time protection again after installation complete.
Restarting the machine worked for me.
I had this problem on MAC. I just added 'sudo' before the command and it worked.
sudo npm install -g parcel-bundler
I tried opening CMD with Run as Admisnistrator then run npm i and it worked for me
I'd just like to add a small little answer based on Qadir Hussain's answer.
If you disable "Realtime Protection" in Windows Security, you're going to leave your laptop or PC vulnerable to any viruses that may infect it when "Realtime Protection" is off. This may seem a bit impossible if you're only installing an NPM package, but some apps may have a hidden background process waiting for "Realtime Protection" to be disabled, and when it is, it could inject a virus.
That been said, there's still an option.
First things first, open Windows Security by typing "Windows Security" in the Start Menu and tap "Open".
After that, go to "Virus & Threat Protection".
Next, scroll down until you find "Manage Settings" under "Virus & Threat Protection Settings".
Then, scroll down until you see "Exclusions". Under "Exclusions" there's a link that says "Add or remove exclusions".
Once that's done, tap the button that says "Add an exclusion". Then tap "Folder" on the drop-down menu.
Choose the node_modules directory that is giving issues.
Last but not least, Allow administrative permissions.
Finally, exit Windows Security.
I wouldn't recommend excluding your entire Projects folder, as that will disable all scans for the directory.
Small disclaimer here, I'm only making this answer as a means of helping others without disabling "Realtime Protection". While I'm not encouraging this, this might help fix a common problem.
Have a good day. :)
For me, there are several possibilities:
Intercepted by anti-virus software, resulting in inoperability.
It is locked by IDE, resulting in inoperable.
The task is locked by npm running, resulting in inoperable.
Cancelling the npm start process and closing the terminal window (I use Hyper Terminal) worked for me (using Win 10).
I was then able to uninstall an npm package and install another.
I had visual studio code running. I turned it off and boom! worked for me!
To me, using Windows 10 the only thing that solved this problem was: exclude the node_modules folder, open Visual Studio Code in Admin mode in the project folder, and execute the following command:
npm install -g --unsafe-perm
For me the issue was with npm version I was using. I changed to a npm version which did not have the bug by using the below command:
npm install --global npm#8.3.1
I found this solution in a github issue:
Link to github issue
Hope it helps you like it did me!
was facing this problem and this is how it got solved :
-stoping the execution of the development server for both front-end and backend:
two things:
try admin.
make sure other processes does not occupying the folder/file
with me, it was not related to antivirus.
it appears that a process occupied this folder. in my case a node process occupied my node_modules folder.
i found it out by using process-explorer - i searched the path end found that a node process using this folder(even though I closed it! very common in windows), so i ended this process and then i did not got this error anymore.
I had the same issue What I have done wrong is I had set the npm registry to a local registry, without knowing that I faced this issue once I reset to globally using npm config set registry https://registry.npmjs.org/ error went away.
I tried everything above.
Deleting node_modules and re-installing did the trick for me.
This happened when I tried installing a new npm dependency, jest, with:
npm i --save-dev jest
I got it working by simply rerunning the command.

How do I read npm "conflicting peer dependency" error messages?

I'm in the process of trying to upgrade some npm dependencies of a project I own, and I'm getting a "conflicting peer dependency" error.
I see a lot of questions on this site asking for help fixing such errors. However, I've struggled to find information on what these errors actually mean. I feel like if I understood that, I'd have a chance of figuring out how to solve the problem on my own.
Here's the error message I'm trying to interpret:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: #angular-devkit/build-angular#0.1102.5
npm ERR! node_modules/#angular-devkit/build-angular
npm ERR! dev #angular-devkit/build-angular#"~0.1102.9" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! dev #angular-devkit/build-angular#"~0.1102.9" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: #angular/localize#11.2.10
npm ERR! node_modules/#angular/localize
npm ERR! peerOptional #angular/localize#"^11.0.0 || ^11.2.0-next" from #angular-devkit/build-angular#0.1102.9
npm ERR! node_modules/#angular-devkit/build-angular
npm ERR! dev #angular-devkit/build-angular#"~0.1102.9" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
This can be reproduced by running npm install in the root of this Github branch (I'm using npm 7.10.0.)
My general understanding of a "conflicting peer dependency" error is that some package I depend upon is expressing a peer dependency on a package version spec which does not match the version of that package that I actually have installed.
For example, if my project has direct dependencies on packages A and B, and I have version 12.0.0 of A installed but my version of B has a peer dependency on ^11.0.0 of package A, then I will get a conflicting peer dependency error, because I'm using B with a version of A that it is potentially incompatible with.
Therefore, my best guess as to what this error message could mean is that some package I depend upon has a peer dependency on #angular/localize version spec ^11.0.0 || ^11.2.0-next, but this spec does not match the version of #angular/localize I have installed.
When I look at my package-lock.json, I do see that the node_modules/#angular-devkit/build-angular entry has an entry "#angular/localize": "^11.0.0 || ^11.2.0-next" in its peerDependencies.
However, this is the only mention of #angular/localize anywhere in this file -- or indeed in package.json. I haven't explicitly requested for it to be installed. Furthermore, it is marked as "optional": true in the peerDependenciesMeta of node_modules/#angular-devkit/build-angular. So it's surprising to see an error message related to it.
The error mentions that the specific conflicting peer dependency is #angular/localize#11.2.10. I don't see where that version number is coming from. But regardless, it actually seems to match the dependency specification underneath: if I go to semver.npmjs.com and type in #angular/localize as the package and ^11.0.0 || ^11.2.0-next as the version range, I see version 11.2.10 of the package highlighted in green, indicating that it matches the range.
So I'd really appreciate some help understanding in detail what this error message is telling me. I don't know why npm is trying to install 11.2.10 of #angular/localize, or why it thinks this conflicts with the peer dependency specification of #angular-devkit/build-angular. It feels like I might be misunderstanding this message completely.
I'm guessing this boils down to some kind of incompatibility between the latest published versions of some of the Angular packages. If anyone has any pointers on how this particular error should be fixed, that would be great -- but I'm much more interested in simply understanding what the error message is telling me, so I can work it out for myself.
Recommendation:
Check out Yarn.
I was able to circumvent the issue in NPM by using Yarn instead of NPM. Yarn is basically a wrapper utility around NPM that adds extra features, which are super useful. It's especially helpful for managing NPM dependencies better.
For instance, it can check if a package is already installed on your machine for another project, directly or as a sub dependency, and can reuse that installed version rather than re-installing a copy of the same package; saves space and makes for faster installations, especially with some of the most common dependencies.
So, due to the optimized way Yarn handles dependencies, I think it helps avoid this issue faced by the OP.
Resolution:
First, delete the node_modules folder in your project.
Yarn will complain about any package-lock.json files, so delete that too (or back it up, then delete it). Do not delete package.json, yarn will need that.
Simply install yarn: npm i yarn (you could do this globally, too).
Then run yarn install in your project directory.
Reading through this GitHub issue, it appears my interpretation of the error message was correct, and that this is in fact a bug in npm.
This appears to have been reported as npm/cli/issues/3083; a fix has been merged, so I guess we just have to wait until it gets included in some upcoming npm release.

"PulseTile-RA" cannot run. Is it an npm dependency issue?

I wanted to experiment with this project based on react-admin:
https://github.com/PulseTile/PulseTile-RA
So I downloaded the code, run npm install and I got a lot of errors from NPM mainly axios version corrupted.
Example:
npm ERR! code EINTEGRITY
npm ERR! sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= integrity checksum failed when using sha1: wanted sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI= but got sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g== sha1-/z8N4ue10YDnV62YAA8Qgbh7zqM=. (75833 bytes)
npm WARN tarball tarball data for js-yaml#3.13.1 (sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ==) seems to be corrupted. Trying one more time.
npm ERR! code EINTEGRITY
npm ERR! sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== integrity checksum failed when using sha512: wanted sha512-pZZoSxcCYco+DIKBTimr67J6Hy+EYGZDY/HCWC+iAEA9h1ByhMXAIVUXMcMFpOCxQ/xjXmPI2MkDL5HRm5eFrQ== but got sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==. (74050 bytes)
npm WARN tar ENOENT: no such file or directory, open 'C:\nodejs\xxx\PulseTile-RA\node_modules\.staging\babel-plugin-transform-object-rest-spread-7e34a6f0\package.json'*
When I do npm start I get an error that react-scripts doesn't exist.
I tried workarounds for similar errors on stackoverflow but without success. And yet still, I cannot get it to run. I have latest NPM, node on windows 10.
Please advise on NPM issues as I think this is the source of this project issue of not starting.
Thank you
So technically, this has more to do with npm than the actual project.
In fact, this issue reported to the npm repository would help.
But here are some quick steps that should help:
Since you're in windows-10, it's advisable to run the "delete" commands within git bash.
Go to the project directory (root folder)
Delete the node_modules directory: rm -rf node_modules
Delete package-lock.json file:rm package-lock.json`
Clear the cache: npm cache clean --force
Run npm install --verbose
If it doesn't help, then please follow more instructions here

`npm install` gives ENOENT errno -2 re missing dezalgo module

I'm trying to run npm install for a little ember-driven site that I've got, but it throws the following error:
npm ERR! path /Projects/Etc/Admin/cuscus/node_modules/npm/node_modules/dezalgo
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Projects/Etc/Admin/cuscus/node_modules/npm/node_modules/dezalgo' -> '/Projects/Etc/Admin/cuscus/node_modules/npm/node_modules/.dezalgo.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mick/.npm/_logs/2018-01-09T01_18_51_322Z-debug.log
If I delete the node_modules directory completely then run npm install again it seems to work, but running it again fails.
What you can try is:
Be sure that you use cmd promt in Admin mode.
If you use VS Code, kill all node procceses. Close it and try again.
Delete package-lock.json and node-modules folder and try again.
Change the node version. For example try the old one v6.11.2
Try to do npm cache clean --force
Try to remove {package}.DELETE in ~/AppData/Roaming/npm/node_modules after the initial npm i -g {package} and retry npm i -g {package}
One of it can help. But not for sure. The status of issue with this problem is open for the moment.
https://github.com/npm/npm/issues/17444
I just had this issue when setting up a new machine. None of the cache clean/uninstall/reinstall steps worked for me.
However, I was able to resolve it by updating npm to the latest version. I had 5.6.0 installed, but using npm-windows-upgrade to install the latest version (5.7.1) cleared up the dependency issues.
See this answer for more information on upgrading npm on Windows:
https://stackoverflow.com/a/31520672/91189
This most likely happened because you updated your node version and because you probably already had this repo sitting on your machine before that particular update, the package-lock.json file whose sole purpose is to track the present and past state of your node_modules file and maintain a very updated dependency tree such that amongst entities using your code there will be consistency installing exactly the same dependencies ;
Entities using your code include
Teammates
Deployments (AWS ECS),
and Continuous integration tools like Travis CI that are running your code,
Try to delete the package-lock.json file. Run the npm install command and you should be fine.
The last thing you should try doing is deleting the missing package if you are not sure of what you are doing, it's usually better to avoid this.
Goodluck.