How to fix "Could not resolve any esbuild targets" when building assets

Posted . Visible to the public.

I recently encountered this error as I was trying to build assets:

$ node esbuild.config.js
.../node_modules/esbuild-plugin-browserslist/dist/resolveToEsbuildTarget.js:43
        throw new Error('Could not resolve any esbuild targets');
        ^

Error: Could not resolve any esbuild targets
    at resolveToEsbuildTarget (.../node_modules/esbuild-plugin-browserslist/dist/resolveToEsbuildTarget.js:43:15)
    at Object.resolveToEsbuildTarget (.../node_modules/esbuild-plugin-browserslist/dist/index.js:9:64)
    at Object.<anonymous> (.../esbuild.config.js:33:55)

The error message about "esbuild targets" was confusing me as it had worked fine just a few weeks ago and there had been no changes since.

Long story short: The browserslist database was simply outdated and the project's browserslist config specifies "last 2 years" -- which no longer resolved to any known browsers, because the package version was older than 2 years.

So, the fix is to just upgrade that package which you should do regularly anyway.
You may also want to upgrade the esbuild-plugin-browserslist package just to ensure compatibility with the latest browserslist version.

yarn upgrade browserslist esbuild-plugin-browserslist

If you want a less invasive upgrade, update only the update-browserslist-db package, but you should be fine just updating browserslist itself.

(This project used yarn, but it affects projects with pnpm or npm just as well. Also note that this is not specific to esbuild, the error message is maybe just more confusing than it should be.)

Profile picture of Arne Hartherz
Arne Hartherz
Last edit
Arne Hartherz
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2026-03-10 08:13)