"npx create-react-app ..." audit comes with 3 high severity issues. How can I fix this? - create-react-app

I have a few react projects that were started using "npx create-react-app" and if I run "npm audit" they come back with:
# npm audit report
immer <8.0.1
Severity: high
Prototype Pollution - https://npmjs.com/advisories/1603
fix available via `npm audit fix --force`
Will install react-scripts#2.0.5, which is a breaking change
node_modules/react-dev-utils/node_modules/immer
react-dev-utils >=6.0.6-next.9b4009d7
Depends on vulnerable versions of immer
node_modules/react-dev-utils
react-scripts >=2.0.6-next.9b4009d7
Depends on vulnerable versions of react-dev-utils
node_modules/react-scripts
3 high severity vulnerabilities
To address all issues (including breaking changes), run:
npm audit fix --force
I have tried running npm audit fix and that doesn't fix the issue.
I have tried running npm audit fix --force which results in even more errors.
I have tried running npm i immer#8.0.1 which also does not work.
I am using nvm with node version 14.15.5 and npm version 7.5.4. I recently updated nvm to the latest version (0.37.2) and changed the default to the latest node lts (14.15.5), so I believe this may be the culprit but I can't figure out how to fix these 3 vulnerabilities.
A possibility is that there's an issue with me having not moved my global packages to the newer version of node.
Any help is much appreciated.

The issue has now been fixed. Just run npm audit fix.

Related

Trouble installing Ganache on fresh WSL

I'm new to coding. I'm using Windows10 and just installed a WSL. I want to install Ganache using the command npm install -g ganache-cli but it says it has 8 vulnerabilities (7 moderate,1 high)
When I write npm audit fix or npm audit fix --force it says that there are no vulnerabilities. I don't understand where the problem is.
My NPM version is 8.3.0
There's no real reason to be alarmed about the vulnerabilities npm report, especially for a new project. Most of the time, these vulnerabilities won't actually affect your project. Be careful using npm audit fix especially npm audit fix --force because it can upgrade or downgrade packages, affecting functionality. If you do use it and it says 0 vulnerabilities after, that means it fixed all of them.
Packages are open-sourced so the community would spot any damaging or sneaky code, especially popular packages such as ganache-cli.
Read more here: https://www.voitanos.io/blog/don-t-be-alarmed-by-vulnerabilities-after-running-npm-install/

NativeScript 8.0.0: NPM vulnerabilites switching between "3 high" to "30 high"

I am currently working on a NativeScript project that uses NativeScript core ~8.0.0 and I just ran an npm install and realized that there are 3 high vulnerabilities. When I try to fix them using npm audit fix (even with --force flag) I end up having 30 hight vulnerabilites. Again npm audit fixleads to the original 3 high again.
These seem to be due to #nativescript/webpack:5.0.0 which is the current version but relies on a vulnerable version of #pmmmwh/react-refresh-webpack-plugin.
Any ideas on how to solve this problem?
Here is the detailed output of npm audit:
Uncontrolled Resource Consumption in ansi-html - https://github.com/advisories/GHSA-whgm-jr23-g3j9
fix available via `npm audit fix --force`
Will install #nativescript/webpack#4.1.0, which is a breaking change
node_modules/ansi-html
#pmmmwh/react-refresh-webpack-plugin <=0.5.0-rc.6
Depends on vulnerable versions of ansi-html
#nativescript/webpack >=5.0.0-alpha.0
Depends on vulnerable versions of #pmmmwh/react-refresh-webpack-plugin
node_modules/#nativescript/webpack
Nervermind, ns migrate did the trick.
Still if anyone is facing a similar problem with the ansi-html package there is a solution for that in this answer.

What does "npm audit fix" exactly do?

npm audit fix is intended to automatically upgrade / fix vulnerabilities in npm packages. However, I haven't found out what it exactly does to fix those vulnerabilities.
I assumed that npm audit fix would upgrade dependencies and dependencies' dependencies to the latest versions that are allowed by the semver-definitions of the packages – effectively the same as rm package-lock.json; npm install. However npm audit fix still performs a lot of changes after lock file removal + reinstall.
What exactly does npm audit fix do? Does it for example install versions of dependencies newer than those allowed by the corresponding package.json (but still semver-compatible)?
From NPM's site on their audit command:
npm audit fix runs a full-fledged npm install under the hood
And it seems that an audit fix only does semver-compatible upgrades by default. Listed earlier in the document:
Have audit fix install semver-major updates to toplevel dependencies, not just semver-compatible ones:
$ npm audit fix --force
As for the lock file, it is regenerated each time you run a command that changes package.json. There is more information about that in an answer here as well as in the official documentation.
In my understanding is not only "upgrading" but sometimes also downgrading in order to install the stable version that fix the issue, sometimes those issues comes in newer versions that maybe have introduced bugs or simply do not match with previous package's API etc.
E.g in my case for example npm install have upgrade react-script to 5.0.0 that has some issue and after have run:
npm audit fix --force
The force flag does : To address all issues (including breaking changes), run: npm audit fix --force
it installed the 3.0.1 with following message:
npm WARN audit Updating react-scripts to 3.0.1,which is a SemVer major change.
So it does the upgrade to the stable version of that package that fix the issue.
On top, though docs state "is running npm install under the hood" but not in the sense of installing newest version of a dependency, but could be useful also to check what happens with npm ci What is the difference between "npm install" and "npm ci"?

How to fix Missing Origin Validation error for "webpack-dev-server" in npm

npm audit
=== npm audit security report ===
Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance
High Missing Origin Validation
Package webpack-dev-server
Patched in >=3.1.6
Dependency of laravel-mix [dev]
Path laravel-mix > webpack-dev-server
More info https://nodesecurity.io/advisories/725
found 1 high severity vulnerability in 11710 scanned packages
1 vulnerability requires manual review. See the full report for details.
How to fix this i cannot use laravel
whenever i try run command "npm run dev" it shows several problem
This audit is just pointing out a vulnerability in your version of the webpack-dev-server package.
I don't think it's related to the other problems you're encountering when you run npm run dev as I'm currently using a vulnerable version of the same package in my dev environment as well and it works fine.
If you're using laravel mix, it is dependent on a vulnerable version of webpack-dev-server (2.11.1) so you can't really fix this problem and will see this annoying audit message until laravel mix is updated to use a newer, secure version.
Maybe you must wait to update laravel-mix.
Ref link: https://github.com/JeffreyWay/laravel-mix/issues/1809
Because version of webpack-dev-server < 3.1.6 in laravel-mix.
Quick solution:
Turning off npm audit on package installation
https://docs.npmjs.com/auditing-package-dependencies-for-security-vulnerabilities

NPM install error? Vulnerabilities found

Recently, I have been getting this error and do not know how to fix. I never gotten this error before.
npm install
output:
42 vulnerabilities found
I tried using npm audit and ran the npm update _____, but it didn't resolve vulnerabilities. What causing this and how do i fix?
you can fix this by running command npm audit fix this will try to fix all issues (mostly by updating packages).
the problem is that npm update only updates some minor versions (and package.lock.json) so if issue is fixed in major version than npm update wont fix this. you can use npm-check to quickly update all your dependencies.