{"id":175,"hash":"7674ac705efe9b41fb31421499a21908c885996224b9d313c954dd86a52be06b","pattern":"Get error to build my project in Vite - Top-level await is not available in the configured target environment","full_message":"I try to build my project in vite,\n\nmy project - https://github.com/yakovcohen4/starbucks-openlayers\n\nI run npm run dev and all work.\n\nbut when I run to build it I get an error.\n\nerror message:\nTop-level await is not available in the configured target environment (\"chrome87\", \"edge88\", \"es2019\", \"firefox78\", \"safari13.1\")\n\nI try to fetch a data and think here is the problem\nlink (line 22+23) -  https://github.com/yakovcohen4/starbucks-openlayers/blob/main/starbucks-project/src/main.ts\n\nconst shopsData = await fetchStarbucksShops();\n\nIf anyone encounters this curse I would be happy to help","ecosystem":"npm","package_name":"typescript","package_version":null,"solution":"For those who experience the same issue in the both dev and build commands, add the following\n\n// vite.config.js\nexport default defineConfig({\n  optimizeDeps: {\n    esbuildOptions: {\n      target: 'esnext'\n    }\n  },\n  build: {\n    target: 'esnext'\n  },\n  // more config options ...\n})","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/72618944/get-error-to-build-my-project-in-vite-top-level-await-is-not-available-in-the","votes":69,"created_at":"2026-04-19T04:41:28.220268+00:00","updated_at":"2026-04-19T04:51:09.959247+00:00"}