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] Vue3 Error: Cant find variable: GlobalThis
- [Solved] Some chunks are bigger warning on vite packaging
- [Solved] Vite packing error: some chunks are larger than 500kb after minification
- After Vite starts, it will prompt “network: use ` — host ` to expose”, and the service cannot be accessed through network IP
- [Solved] Error: Transform failed with 1 error: error: Invalid option in transform() call: “jsx“
- [Solved] Vue3 process Error: Uncaught ReferenceError: process is not defined
- [Solved] Error:Plugin/Preset files are not allowed to export objects, only functions
- [Solved] Syntax Error: Error: No ESLint configuration found & TypeError: eslint.CLIEngine is not a constructor
- Vue Install less Error: While resolving: [email protected]
- [Solved] Component name “login“ should always be multi-word.
- Vue3 Error: [vue/no-multiple-template-root] The template root requires exactly one element
- [Solved] Vue Use gzip Package Error: Rule can only have one resource source
- [Solved] Vue 3 Script Setup ESLint Error: ‘defineProps‘ is not defined
- Vuepress build error: window is not defined [How to Solve]
- vue.config.js build Package UglifyJsPlugin to clear console and print console.log Error: `warnings` is not a supported option
- [Solved] Temporary error: Error: spawn E:\vue3-vite\my-app\node_modules\esbuild\esbuild.exe ENOENT
- Error: Duplicate plugin/preset detected [How to Solve]
- [Solved] Npm install Error: verbose stack Error: unable to resolve dependency tree
- [Solved] Vue item error: Regeneratorruntime is not defined
- [Solved] NUXT.JS. npm run dev Error: Error: error:0308010C:digital envelope routines::unsupported