npm upgrade and npm audit fix: problems with vulnerabilities (upgrading react-scripts) - node.js

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!

Related

Npm audit fix --force not working. Can't use npm

I have a problem with npm, when I try to install a package using npm it shows this error.
I tried to upgrade expo, reinstall expo and run npm audit fix --force but none of them worked.
qs 6.7.0 - 6.7.2
Severity: high
qs vulnerable to Prototype Pollution - https://github.com/advisories/GHSA-hrpp-h998-j3pp
fix available via `npm audit fix --force`
Will install expo#44.0.6, which is a breaking change
node_modules/qs
body-parser 1.19.0
Depends on vulnerable versions of qs
node_modules/body-parser
#expo/dev-server *
Depends on vulnerable versions of body-parser
node_modules/#expo/dev-server
#expo/cli >=0.1.0
Depends on vulnerable versions of #expo/dev-server
node_modules/#expo/cli
expo >=45.0.0-beta.1
Depends on vulnerable versions of #expo/cli
node_modules/expo
5 high severity vulnerabilities

npm WARN deprecated fsevents#1.2.4: fsevents 1 will break on node v14+

I keep getting this npm warning after running npm install. I have deleted and reinstalled npm. Nothing seems to work.
npm WARN deprecated fsevents#1.2.4: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
up to date, audited 2107 packages in 26s
94 packages are looking for funding
run `npm fund` for details
68 vulnerabilities (14 low, 18 moderate, 32 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.
first try to reset npm cache
npm cache clean --force
then retry to install npm packages
if nothing happens, try npm install --no-optional or npm install --force
hope that works
The problem isn't with npm, but with your project. It requires (possibly indirectly), fsevents#1.2.4, which is deprecated. You'll need to update your project to require a newer version, e.g.:
"fsevent": "^2.3.2"
and of course, update your project to work with this version.

error when I setting up REACT environment

I'm trying to install react native on my Mac through the terminal using "sudo npm install -g expo-cli" but at the end of the installation errors appear.
115 packages are looking for funding
run `npm fund` for details
31 vulnerabilities (19 moderate, 12 high)
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.
Before trying to install react native I obviously installed nodeJS (16) in its latest version.
Anyone have an idea why the installation doesn't work?
when I do "npm audit fix" this is what it says:
npm ERR! code ENOLOCK
npm ERR! audit This command requires an existing lockfile.
npm ERR! audit Try creating one first with: npm i --package-lock-only
npm ERR! audit Original error: loadVirtual requires existing shrinkwrap file
Thank you in advance for your help.
Good news!
The first block you're referring to does not indicate installation failure. Your packages were installed correctly. The warnings are for nested security vulnerabilities which you can choose to address or ignore, depending on your app.
To prove that it was installed, run npm list -g in your terminal and see if expo-cli is in the list.
You can also check the packages installed correctly by creating a new react app using
npx create-react-app my-app
cd my-app
npm start
npm audit fix is intended to automatically upgrade / fix vulnerabilities in npm packages

Node.js reports "Use-After-Free" vulnerability with puppeteer

I started a new npm repo (running in an official node docker container), installed the puppeteer package, and got a "high" severity vulnerability warning:
# node --version
v15.13.0
npm --version
7.8.0
# npm list
puppeteer#1.0.0 /home/node/puppeteer
`-- puppeteer#8.0.0
# npm audit
# npm audit report
puppeteer <1.13.0
Severity: high
Use-After-Free - https://npmjs.com/advisories/824
fix available via `npm audit fix`
1 high severity vulnerability
To address all issues, run:
npm audit fix
The puppeteer package version is obviously greater than 1.13.0, but it still warns about this "Use-After-Free" vulnerability. Needless to say, npm audit fix doesn't fix anything. What's going on?

Update Every Existence Of A Certain Package Within My node_modules

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.

Resources