Get error to build my project in Vite - Top-level await is not available in the configured target environment
Full error message
I try to build my project in vite,
my project - https://github.com/yakovcohen4/starbucks-openlayers
I run npm run dev and all work.
but when I run to build it I get an error.
error message:
Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")
I try to fetch a data and think here is the problem
link (line 22+23) - https://github.com/yakovcohen4/starbucks-openlayers/blob/main/starbucks-project/src/main.ts
const shopsData = await fetchStarbucksShops();
If anyone encounters this curse I would be happy to helpSolutionsource: stackoverflow \u2197
For those who experience the same issue in the both dev and build commands, add the following // vite.config.js export default defineConfig({ optimizeDeps: { esbuildOptions: { target: 'esnext' } }, build: { target: 'esnext' }, // more config options ... })
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/7674ac705efe9b41fb31421499a21908c885996224b9d313c954dd86a52be06bhash \u00b7 7674ac705efe9b41fb31421499a21908c885996224b9d313c954dd86a52be06b