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 package was simply outdated and its project 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 have to also want upgrade the esbuild-plugin-browserslist package to ensure you can use the latest browserslist version.
yarn upgrade browserslist esbuild-plugin-browserslist
(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.)