Vue Use the top-level await Error [How to Solve]

Use the top-level await in Vue to generate an error reporting solution

1. Version information

vue:3.2.16

vite:2.6.4

node:17.1.0

2. Error message

error during build:
Error: Transform failed with 1 error:
assets/index.867f4832.js:187:9: error: Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2019", "firefox78", "safari13.1")

3. Solution

Add the following code in vite.config.js

export default defineConfig({
  plugins: [vue()],
  build:{
    target:['edge90','chrome90','firefox90','safari15']
  }
})

Similar Posts: