vue add i18n在vuejs3和@vue/cli 4.5.4中遇到错误,错误意味着什么以及如何调试



当我尝试vue添加i18n时,我正在运行此错误:

🚀  Invoking generator for vue-cli-plugin-i18n...
ERROR  Error: You cannot call "get" on a collection with no paths. Instead, check the "length" property first to verify at least 1 path exists.
Error: You cannot call "get" on a collection with no paths. Instead, check the "length" property first to verify at least 1 path exists.
at Collection.get (/usr/local/lib/node_modules/@vue/cli/node_modules/jscodeshift/src/Collection.js:213:13)
at injectOptions (/usr/local/lib/node_modules/@vue/cli/lib/util/codemods/injectOptions.js:15:6)
at runTransformation (/usr/local/lib/node_modules/@vue/cli/node_modules/vue-codemod/dist/src/run-transformation.js:61:17)
at Object.keys.forEach.file (/usr/local/lib/node_modules/@vue/cli/lib/Generator.js:290:23)
at Array.forEach (<anonymous>)
at Generator.resolveFiles (/usr/local/lib/node_modules/@vue/cli/lib/Generator.js:276:24)
at process._tickCallback (internal/process/next_tick.js:68:7)

vue-add命令之前的package.json如下所示:

{
"name": "com.food-cheatsheet",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"vue": "^3.0.0-0",
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0-0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0-0",
"tailwindcss": "^1.7.5"
}
}

到目前为止,我用vue create建立了这个项目,并安装了tailwindcss和postss。

你能描述一下我,这个错误到底意味着什么吗?我想这与i18n无关,但当我使用add时,它也会出现在其他模块中

  • npm install vue-i18n作品(仅供参考(

附加问题

如何在vuejs3.0中设置i18n?vuejs2和3之间的区别在哪里?

vuetifyjs的相同问题https://github.com/vuetifyjs/vue-cli-plugins/issues/140

用于vue 3

npm install --save vue-i18n@next
yarn add vue-i18n@next

并手动配置i18n

vue-i18n-next:的例子

使用可组合API 的示例

使用传统API 的示例

示例目录

如果要安装vue add i18n,请更改

createApp(App)
.use(store)
.use(router)
.mount("#app");

new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");

对于typescript项目,添加vue-i18n.d.ts文件,内容为

declare module "vue-i18n"

对于vue 3,我安装npm install --save vue-i18n@next而不是vue add i18n

相关内容

最新更新