你可能在使用 vuex 4.0.1, 將它降級為 vuex 4.0.0 即可解決。 vuex #1992
如果仍然報錯看這個情況。你可能在使用 vite 同時使用 vue-i8n,然后在 vite.config.ts 配置了 alias 解決 vue-i18n 開發環境下的一個警告(vue-i18n.esm-bundler.js:46 You are running the esm-bundler build of vue-i18n.)。
alias: {
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
}
僅在生產環境下配置即可解決這個生產環境錯誤
export default ({ mode }) => {
const __DEV__ = mode === 'development'
const alias: Record<string, string> = {
'@/': `${resolve(__dirname, 'src')}/`,
}
if (__DEV__) {
// 解決警告You are running the esm-bundler build of vue-i18n.
alias['vue-i18n'] = 'vue-i18n/dist/vue-i18n.cjs.js'
}
return defineConfig({
resolve: {
alias,
},
})
}
