I have this error whenever I install a package
found 14 vulnerabilities (1 low, 1 moderate, 12 high) run `npm audit fix` to fix them, or `npm audit` for details
So I have found out that some of my npm packages have a vulnerable version of a
dependency called tar. So all I need to do now is update this package to a higher version >= 4.4.2.
I manually changed the versions of all the tar dependencies in my package-lock.json and have tried to run the following commands
npm i
npm audit fix
npm audit fix --force
but the package-lock.json updates itself back to it's previous tar dependencies. I even ran npm cache clean --force and repeated the above command but the same result.
Is there a way I can specifically update every tar dependency within my node_modules from the command line?
npm audit fix changes package.json if needed by changing package versions to compatible ones, and package.json defines the possible versions that appear in package-lock.json.
So, you can't fix version-based vulnerabilities by rewriting package-lock.json because npm install rewrites package-lock.json anyway.
npm audit fix rewrites the versions in package.json to compatible versions that don't suffer from vulnerabilities. If running npm audit fix doesn't fix your version-based vulnerability issues, you have to refactor your code by using versions/libs that are not entirely compatible in the eyes of npm audit fix (in the real world, the changes are usually very minor). You can use the help of npm list to get the name of the dependency that requires an invalid version of tar, and change the version of this package.
Related
Can anyone please tell me why react- router- dom is not installing in my vs-code and how to fix it.
It showing 6 high vulnerability, I also run npm audit fix --force and npm audit but nothing happened.
Please tell me how to remove these vulnerability
Just tried it, react-router-dom installs and also works on your part as I can see.
Try to fix the vulnerabilities by doing these steps:
npm outdated // run to check outdated npm packages
npx npm-check-updates -u // run to check updates outdated npm packages
npm install // run to update npm packages
Source: https://stackoverflow.com/a/70920497/12772716
Whenever I run the command npm install package-name, it doesn't show any error and it also does not install the package(no node_modules folder, just does nothing). Here is the kind of message I get:
up to date, audited 248 packages in 11s
8 packages are looking for funding run npm fund for details
19 vulnerabilities (6 moderate, 9 high, 4 critical)
To address issues that do not require attention, run: npm audit fix
To address all issues (including breaking changes), run: npm audit
fix --force
Run npm audit for details.
I have also tried npm i package-name and npm install --save package-name, but all give the same message. I'm currently using Node version 18.12.1.
What could I be doing wrong and what could be causing this issue?
In order to install npm packages locally, you should run the
npm init
command first.
A file called package.json will be created which contains basic information about the project and the dependencies used in it.
Then in the same directory run the installation command.
Silly me. The fix was to initialize npm in the folder. I ran npm init -y and everything works fine now.
When I run npm update -g, I get this enormous list of vulnerabilities on the screenshot
I tried to globally update npm to the latest version, and I tried to install npm-check-updates. I updated something with it, and now ncu -g gives me 'All global packages are up to date'.
npm audit fix and npm audit fix --force don't do anything.
Yet, all the vulnerabilities are still here. What can I do about it?
Here's list of globally installed packages I have:
And here's the output of npm audit fix and npm audit fix --force while I'm in the directory where the global packages are installed:
If I delete package-lock.json, npm audit fix doesn't run at all and wants me to initialize npm in this global packages directory with package-json.only. After doing so, it gives me the output from above.
How can I fix these vulnerabilites? Or do I need to care about them at all?
If I run npm upgrade or npm upgrade react-scripts I've always got the message like
added 84 packages, removed 249 packages, changed 428 packages, and audited 1245 packages in 57s
179 packages are looking for funding
run `npm fund` for details
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
Run `npm audit` for details.
So I try npm audit fix --force and get a long report about dependencies and the text
66 vulnerabilities (15 low, 26 moderate, 24 high, 1 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
I follow these steps and run npm audit fix --force witch caused into errors:
npm ERR! code ERR_INVALID_ARG_TYPE
npm ERR! The "from" argument must be of type string. Received undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\{user}\AppData\Local\npm-cache\_logs\2022-05-09T15_11_33_120Z-debug-0.log
If I try to run npm audit fix --force instead of npm audit fix I'm get the following:
nth-check <2.0.1
Severity: moderate
Inefficient Regular Expression Complexity in nth-check - https://github.com/advisories/GHSA-rp65-9cf3-cjxr
fix available via `npm audit fix --force`
Will install react-scripts#2.1.3, which is a breaking change
node_modules/svgo/node_modules/nth-check
css-select <=3.1.0
Depends on vulnerable versions of nth-check
node_modules/svgo/node_modules/css-select
svgo 1.0.0 - 1.3.2
Depends on vulnerable versions of css-select
node_modules/svgo
#svgr/plugin-svgo <=5.5.0
Depends on vulnerable versions of svgo
node_modules/#svgr/plugin-svgo
#svgr/webpack 4.0.0 - 5.5.0
Depends on vulnerable versions of #svgr/plugin-svgo
node_modules/#svgr/webpack
react-scripts >=2.1.4
Depends on vulnerable versions of #svgr/webpack
node_modules/react-scripts
6 moderate severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
And no, running npm audit fix --force once again does not help.
Can somebody help me?
As the new version 6.3.0 doesn't have the proper #svgo and #svgr we won't be able to access those modules. So, my suggestion is to go with the older version that is 5.2.0.
Instead of using the latest version use the older version
npm install react-router-dom#5.2.0
By running the above code in the promt we can access all the services of "react-router-dom".
Thank you :)
I was hung up on this problem too and got past it by updating my npm version to the latest, then for the specific package I was trying to update that caused the problem in the first place, I uninstalled and reinstalled it. I still get the 69 vulnerabilities message but the update did actually work. Good luck!
There is something I don't understand with how npm audit fix works. From the docs:
npm audit fix runs a full-fledged npm install under the hood
So why when I run npm install and see audit vulnerabilities do I have to run npm audit fix manually to fix them?
npm install without any arguments will just install the dependencies in your package-lock.json (assuming it exists). npm audit fix will use the audit information to figure out what dependencies need to be upgraded and install them, as long as they don't conflict with your package.json.