While running the following cli command
npx browserslist@latest --update-db
I'm getting the following error:
Error: Command failed: npm install caniuse-lite
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
...
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
Usually, I'm using the --force
flag when running npm install --force
, however, I didn't find a way to cause the cli command mentioned above to be run with this flag.
Is there an environment param or a flag that might help me?
BTW, I don't want to use the following command:
npm install caniuse-lite@latest --force
because I'm running it in the pre-commit
hook, and that command doesn't stage it, while I think the first one does.
If anyone else has a way to automatically update browserslist
or caniuse-lite
, or to suppress their warning when they are out-of-date, that also would be useful.
Faced the same issue after NodeJS/npm update to latest LTS version.
According to this explanation, the root cause is in changed npm behavior when it encounters conflicting peerDependencies (warnings are errors now).
As of now, we've solved the issue by adding .npmrc (npm config file) to the root of our project with the following line:
Source: link