Npm install gives warnings, npm audit fix not working

node.jsAngularNpm

node.js Problem Overview


I am working on an angular app with a .net core web api.

When I cloned this repository, I tried to run npm install on the angular application, but I got a strange error:

npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})




audited 34090 packages in 14.711s
found 15 vulnerabilities (9 low, 6 high)
run npm audit fix to fix them, or npm audit for details 

audited 34090 packages in 14.711s found 15 vulnerabilities (9 low, 6 high) run npm audit fix to fix them, or npm audit for details

Also, if I try to do npm audit fix, I get even more errors:


npm audit fix
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 @progress/kendo-theme-default@file:https:/registry.npmjs.org/@progress/kendo-theme-default/-/kendo-theme-default-2.48.1.tgz does not satisfy @progress/kendo-theme-default@file:lib/kendo-theme-default
npm ERR!     Invalid: lock file's bootstrap@file:https:/registry.npmjs.org/bootstrap/-/bootstrap-4.0.0.tgz does not satisfy bootstrap@file:lib/bootstrap

How can I resolve this?

node.js Solutions


Solution 1 - node.js

Often times, this is related to package-lock.json messing. I would suggest to try to:

1 - Delete your package-lock.json

2 - Delete your node_modules folder

3 - Try npm install again

This used to fix several issues when adding new packages in my angular apps.

Good luck!

Solution 2 - node.js

The best thing I recently learn was install the [npm-check-updates][1]. It does everything automatically.

run ncu for list in my case was this:

 $ ncu
    
 babel-core           ^6.26.0  →  ^6.26.3
 babel-loader          ^7.1.5  →   ^8.0.6
 babel-preset-env      ^1.6.1  →   ^1.7.0
 copy-webpack-plugin   ^4.6.0  →   ^5.0.5
 style-loader         ^0.20.2  →   ^1.0.1
 webpack                4.0.04.41.2

then run ncu -u to upgrade automatically. [1]: https://github.com/tjunnone/npm-check-updates

Solution 3 - node.js

Upgrade all packages or at least reinstall them. Warning upgrading packages may cause issue with your code. back up everything first.

  1. copy list of all your dependencies and remove them from package.json

{ "private": true, "scripts": { "dev": "next dev", "build": "next build", "start": "next start" }, "dependencies": {

} }

  1. reinstall using npm i "each package with new or existing version- @version"

Solution 4 - node.js

I had the same problem when I tried to install a package. Try installing globally with a sudo command like this:

sudo npm install -g <package name>

I am using WSL and this method worked for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAyush M.View Question on Stackoverflow
Solution 1 - node.jsCodeMylifeView Answer on Stackoverflow
Solution 2 - node.jsrldView Answer on Stackoverflow
Solution 3 - node.jsSergei BView Answer on Stackoverflow
Solution 4 - node.jsAbdullah Al NahianView Answer on Stackoverflow