solution
1. Background description
When the project is packaged recently, there is no problem with the local package and it can run normally, but once it is automatically built and released through CI/CD, an error will be reported Browserslist: caniuse-lite is outdated. Please run: npx update-browserslist-db @latest, and terminate compilation and packaging
The picture below is the error message reported by the local computer when packaging, but it will not affect the project construction and packaging in the end, and the packaging can be successful.
However, once the automatic build and release is performed through CI/CD, an error will be reported and the packaging will end, which will eventually cause the packaging to fail.
Two, the solution
2.1 Solution 1: Reinstall caniuse-lite, browserslist
Find two folders under the node_modules folder of the project on the local computer: caniuse-lite and browserslist. And delete the two folders caniuse-lite and browserslist.
Then run the following command to reinstall caniuse-lite and browserslist.
Repackage the project on the local computer, test it, and submit the package.json file to the svn server after the test, so that jenkins will reacquire the dependent packages when it is packaged again.
npm i caniuse-lite browserslist -S
You can refer to the following sample pictures:
After executing the reinstallation command, if the content shown in the figure below appears, it means that the reinstallation of the two files is successful.
After reinstallation, two dependent packages will appear in the package.json file in the project, as shown in the following figure:
2.2 Solution 2: npm update caniuse-lite browserslist
Here we are prompted that we need npm update. It should be noted that we cannot directly npm update, because this will update all our dependent packages. We need to bring the package name, so we should write the command like this:
npm update caniuse-lite browserslist
3. Expansion
The introduction of caniuse-lite and browserslist, if you want to learn more related knowledge, please refer to the following introduction.
browserslist:https://www.npmjs.com/package/browserslist
caniuse-lite:https://www.npmjs.com/package/caniuse-lite
This article is over!