Reputation: 31
I'm using latest version of react-scripts npm package i.e. 4.0.3 in my react project and it has a vulnerabilities with one of his dependency package called browserslist, I was trying to resolve this vulnerability by adding this package under the resolutions section in my package.json file. I tried to override the package version with the help of preinstall command npx npm-force-resolutions and it will install the version we specified under the resolutions. My package.json file will be
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "react-scripts start",
"preinstall": "npx npm-force-resolutions",
"build": "react-scripts build"
},
"author": "",
"license": "ISC",
"dependencies": {
"react-scripts": "^4.0.3"
},
"resolutions": {
"browserslist": "4.16.6"
}
}
When I run the npm install the preinstall script will run and it will installing the browserslist package version after that I tried to check the list available vulnerabilities with npm audit command and I got 0 vulnerabilities. Refer https://i.sstatic.net/cp1Sf.png to install command view. Refer https://i.sstatic.net/8dLJz.png to audit command view
After that I tried to run the npm run build command and it will took build script from my package.json file. The build is failing with following error. Refer https://i.sstatic.net/Lt3OE.png to build command view
I did lot of research on this from past 2 weeks but no luck at all. I'm definitely missing something after this. It would be great if anyone can help me on this it will be really appreciate.
Upvotes: 3
Views: 10635
Reputation: 236
Delete your nodemodules folder and package.lock.json file and run npm install.
Upvotes: 3