项目背景:若依框架vue3+vite2
问题一: does not provide an export named ‘createI18n’
根据i18n官网下载导入后,控制台会报上述错误,查询了很多资料,通过更换i18n的版本号,引入方式全部都不可以,均无法解决,后续会把遇到的其他问题也会放入这里
解决办法:
在vite.config.js里面添加’vue-i18n’: ‘vue-i18n/dist/vue-i18n.cjs.js’,具体代码如下:
resolve: {
alias: {
// 清除警告 vue-i18n 控制台警告,解决报错报错The requested module '/node_modules/.vite/deps/vue-i18n.js?v=533d25cb' does not provide an export named 'createI18n'
// You are running the esm-bundler build of vue-i18n. It is recommended to configure your bundler to explicitly replace feature flag globals with boolean literals to get proper tree-shaking in the final bundle.
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
},
},