Browserslist: caniuse-lite is outdated NPM issue [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# Browserslist: caniuse-lite is outdated NPM issue [Solved]

To resolve the "Browserslist: caniuse-lite is outdated" issue, open your terminal in your project's root directory and run the npx browserslist@latest --update-db command.

browserslist caniuse lite is outdated

Here is the complete message.

shell
Browserslist: caniuse-lite is outdated. Please run: npx browserslist@latest --update-db Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating

Open your terminal in your project's root directory (where your package.json file is) and run the following command.

shell
npx browserslist@latest --update-db

npx browserslist update db

You will most likely get prompted whether to install browserslist when you issue the command.

Type y and press Enter to confirm.

The command will:

  1. Remove the old caniuse-lite from your package-lock.json or yarn.lock file.
  2. Install the new caniuse-lite version.
  3. Clear the unnecessary dependencies of the old caniuse-lite version.
  4. Update your target browsers if necessary.

# Use the npm update command if the issue persists

If the message is still shown when you issue an npm command, update your dependencies with the npm update command.

shell
npm update

run npm update

The npm update command respects semver. It updates the packages with a fuzzy version to the latest version and installs missing dependencies.

If you use yarn, use the yarn upgrade command instead.

shell
yarn upgrade

issue yarn upgrade command

# Delete your node_modules and package-lock.json files and reinstall dependencies

If the error persists, delete your node_modules folder and your package-lock.json file and reinstall your dependencies.

If you are on macOS or Linux, run the following commands in bash or zsh.

shell
# for macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on Windows, run the following commands in CMD.

cmd
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean your npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you still see the message after reinstalling your modules, update the browserslist package.

shell
npx browserslist@latest --update-db

# Only deleting the caniuse-lite package from package-lock.json

If you don't want to delete your node_modules folder and your package-lock.json (or yarn.lock) file, you can:

  1. Open your package-lock.json or yarn.lock file.
  2. Look for the caniuse-lite package and delete the object.

The package will likely be named node_modules/caniuse-lite.

delete only caniuse lite entry from package lock

You can use Ctrl + f (or Cmd + f on macOS) to search for caniuse-lite.

Make sure to delete the entire object.

  1. Rerun the npm install or yarn install command after you delete the object.
shell
# with NPM npm install # or with YARN yarn install

If you still see the message after reinstalling your modules, update the browserslist package.

shell
npx browserslist@latest --update-db

If the issue persists, you can also try to delete the caniuse-lite and browserslist folders from your node_modules directory and run the following command.

shell
# with NPM npm install caniuse-lite browserslist # with YARN yarn add caniuse-lite browserslist

# Updating caniuse-lite and browserslist

If the issue persists, try to update the caniuse-lite and browserslist packages.

shell
# with NPM npm install caniuse-lite@latest browserslist@latest # with YARN yarn add caniuse-lite@latest browserslist@latest

If you use the autoprefixer, make sure to update it as well.

shell
# with NPM npm install autoprefixer@latest # with YARN yarn add autoprefixer@latest

Rerun the following command if the issue persists.

shell
npx browserslist@latest --update-db
I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev