ng build - Browserslist: caniuse-lite is outdated. Please run the following command: `npx browserslist --update-db`

373 views Asked by At

I'm trying to deploy an angular aplication, when I run ng build --prod or ng build, I see the error

"Browserslist: caniuse-lite is outdated. Please run the following command: npx browserslist --update-db"

I tried the recomendation above and it didn't fix the problem.  Remove node_module and package-lock.json then npn install and didn't fix it.  I run npx update-browserslist-db@latest and didn't fix.  npm i caniuse-lite browserslist also didn't solved the issue.  Also tryed npm install caniuse-lite@latest --save and nothing happened.

PS .\ClientApp> npx browserslist --update-db
The --update-db command is deprecated.
Please use npx update-browserslist-db@latest instead.
Browserslist DB update will still be made.
Latest version:     1.0.30001564
Installed versions: 1.0.30001035, 1.0.30001564
Removing old caniuse-lite from lock file
Installing new caniuse-lite version
npm install caniuse-lite
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of postcss@^8.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jasmine-core@>=3.8 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\compiler-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

Cleaning package.json dependencies from caniuse-lite
npm uninstall caniuse-lite
npm WARN @angular/[email protected] requires a peer of @angular/[email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of postcss@^8.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of jasmine-core@>=3.8 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@angular\compiler-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

caniuse-lite has been successfully updated

No target browser changes
PS C:\dados\repos\SegregacaodeAcessosWEB\ClientApp> 
----------------------------------------------------------

I'm using VScode to edit a legacy project, possibily created on Visual Studio.

Below is my angular setup:

Angular CLI: 8.2.2
Node: 10.9.0
OS: win32 x64
Angular: 8.2.12
... animations, common, compiler, core, forms, platform-browser
... platform-browser-dynamic, platform-server, router

Package                                    Version
--------------------------------------------------------------------
@angular-devkit/architect                  0.803.29
@angular-devkit/build-angular              0.803.29
@angular-devkit/build-optimizer            0.803.29
@angular-devkit/build-webpack              0.803.29
@angular-devkit/core                       17.0.3
@angular-devkit/schematics                 17.0.3
@angular/cli                               8.2.2
@angular/compiler-cli                      8.2.14
@angular/language-service                  8.2.14
@ngtools/webpack                           8.3.29
@nguniversal/module-map-ngfactory-loader   8.1.1
@schematics/angular                        8.2.2
@schematics/update                         0.802.2
rxjs                                       6.6.7
typescript                                 3.5.3
webpack

In my package.json I can see the dependencies below:

   "browserslist": "^4.22.1",
   "caniuse-lite": "^1.0.30001564",

I checked other similar posts that mention compilerconfig.json but I don1t have this file on my project.

Any help will be appreciated.

2

There are 2 answers

0
Tony Ngo On

Make sure to run

npx update-browserslist-db@latest
0
Daniel On

I have the same controversial issue:

$ npx browserslist@latest --update-db

The --update-db command is deprecated. Please use npx update-browserslist-db@latest instead. Browserslist DB update will still be made. Latest version: 1.0.30001568 Installed version: 1.0.30001279 Removing old caniuse-lite from lock file Installing new caniuse-lite version $ yarn add -W caniuse-lite .........a lot of process...... caniuse-lite has been successfully updated

And it does not work this way all the time

$ npx browserslist@latest --version browserslist 4.22.2