Problem:
browser version 65
globalthis requires chrome 71 or above
vite + vue3.0 after the project is packaged, the browser prompts globalthis is not defined.
How to Solve:
Modify vite.config.js
Add plugin @vitejs/plugin-legacy
import legacy from '@vitejs/plugin-legacy'
export default defineConfig({
plugins: [
legacy({
targets: ['Chrome 63'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
modernPolyfills: true
})
],
build:{
target:'es2015'
}
})
Just repack it
Read More:
- [Solved] vite2+vue3 jsx Error: React is not defined
- [Solved] Vue3 Error: Cant find variable: GlobalThis
- [Solved] Vuepress Package Error: document is not defined
- How to Solve Vite package error
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- [Solved] Vue item error: Regeneratorruntime is not defined
- [Solved] Some chunks are bigger warning on vite packaging
- Vuepress build error: window is not defined [How to Solve]
- [Solved] Vue3 process Error: Uncaught ReferenceError: process is not defined
- [Solved] Vite packing error: some chunks are larger than 500kb after minification
- How to Solve “Vue is not defined” Error
- vue eslint error ‘process‘ is not defined no-undef [How to Solve]
- [Solved] Uncaught ReferenceError: axios is not defined
- [Solved] Nuxt Import qrcodejs2.js / QRCode.js Error: document is not defined
- [Solved] JQuery each Method Error: $XXX is not defined
- Ant design vue table Error: h is not defined [How to Solve]
- After Vite starts, it will prompt “network: use ` — host ` to expose”, and the service cannot be accessed through network IP
- [Solved] webpack Package Error: TypeError: this.getOptions is not a function style-loader
- [Go] Can structure/structure pointer be compared with operator == is not defined error
- [Solved] Vue uses webpack to package error: Createapp is not a function