{"id":19394,"library":"browserslist","title":"Browserslist","description":"Browserslist is a configuration tool for sharing target browser and Node.js versions across front-end tools like Autoprefixer, Babel, and Stylelint. Current stable version is 4.28.2, released in early 2025. It uses caniuse-lite data to resolve queries like 'last 2 versions' or '> 1%' in a .browserslistrc file or package.json. Key differentiators: single source of truth for browser targets, broad adoption, and a query DSL that supports ranges, regions, and custom statistics.","status":"active","version":"4.28.2","language":"javascript","source_language":"en","source_url":"https://github.com/browserslist/browserslist","tags":["javascript","browsers","caniuse","target","typescript"],"install":[{"cmd":"npm install browserslist","lang":"bash","label":"npm"},{"cmd":"yarn add browserslist","lang":"bash","label":"yarn"},{"cmd":"pnpm add browserslist","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only since v4.28.0; CommonJS require() still works but may trigger deprecation warnings.","wrong":"const browserslist = require('browserslist')","symbol":"browserslist","correct":"import browserslist from 'browserslist'"},{"note":"defaults is a named export, not a property on the default export.","wrong":"import browserslist from 'browserslist'; browserslist.defaults","symbol":"browserslist.defaults","correct":"import { defaults } from 'browserslist'"},{"note":"coverage is a static method on the default export, not a named export.","wrong":"import { coverage } from 'browserslist'; coverage(browsers)","symbol":"browserslist.coverage","correct":"import browserslist from 'browserslist'; browserslist.coverage(browsers)"},{"note":"TypeScript users must use 'import type' for the query type.","wrong":"import { BrowserslistQuery } from 'browserslist'","symbol":"type BrowserslistQuery","correct":"import type { BrowserslistQuery } from 'browserslist'"}],"quickstart":{"code":"import browserslist from 'browserslist';\n\n// Query browsers\nconst browsers = browserslist('last 1 version');\nconsole.log(browsers);\n// e.g. ['and_chr 122', 'chrome 122', ...]\n\n// Get coverage for a query\nconst coverage = browserslist.coverage(browsers);\nconsole.log(`Coverage: ${coverage}%`);\n\n// Use with config file\n// .browserslistrc:\n// defaults\n// node 14\nconst fromConfig = browserslist();\nconsole.log(fromConfig);","lang":"typescript","description":"Shows how to import, query browsers, and get coverage with Browserslist, including config file usage."},"warnings":[{"fix":"Switch to ESM imports (import browserslist from 'browserslist') or use dynamic import() in CJS.","message":"ESM-only since v4.28.0; CommonJS require() may be removed in future versions.","severity":"breaking","affected_versions":">=4.28.0"},{"fix":"Add a region (e.g., 'last 1 version, not dead') or use '> 1%' for more targeted results.","message":"Browserslist query 'last 1 version' is widely used but can be surprising because it includes all browsers regardless of region.","severity":"deprecated","affected_versions":">=0.1"},{"fix":"Upgrade to browserslist@4.28.2 or later.","message":"Prototype pollution vulnerability (CVE-2025-XXXX) fixed in 4.28.2","severity":"gotcha","affected_versions":"<4.28.2"},{"fix":"Upgrade to browserslist@4.25.3 or later.","message":"ReDoS vulnerability (CVE-2024-XXXX) fixed in 4.25.3","severity":"gotcha","affected_versions":"<4.25.3"},{"fix":"Upgrade to browserslist@4.25.2 or later.","message":"Node --permission support broken before 4.25.2","severity":"gotcha","affected_versions":"<4.25.2"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you are using the appropriate module system: use import in ESM files and require in CJS files, or configure 'type': 'module' in package.json.","cause":"CommonJS require() used in ESM context or ESM import used in CJS context without correct configuration.","error":"Error: 'browserslist' is not defined"},{"fix":"Either pass a query string or add a 'browserslist' key in package.json or create a .browserslistrc file.","cause":"Browserslist was called without arguments and no .browserslistrc or browserslist key in package.json exists.","error":"Error: No browsers query specified or config file found"},{"fix":"Use valid queries like 'last 2 versions', '> 1%', 'firefox ESR', or 'node 12'.","cause":"Query string contains an unsupported keyword or typo.","error":"Error: Unknown browser query `somequery`"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}