Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue add i18n runs into error with vuejs3 and @vue/cli 4.5.4, what does the error mean and how to debug?

when I try to vue add i18n I am running in this error:

    🚀  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)

The package.json before vue add command looks like this:

{
  "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"
  }
}

I set up the project with vue create and installed tailwindcss and postcss so far.

Can you describe me, what the error actually means? I guess it has nothing todo with i18n but will occure with other modules as well, when I use add

  • npm install vue-i18n works (FYI)

Additional Question

How to setup i18n in vuejs 3.0 ? where are the differences between vuejs2 and 3 here?

like image 665
helle Avatar asked Aug 27 '20 05:08

helle


1 Answers

the same issue with vuetifyjs https://github.com/vuetifyjs/vue-cli-plugins/issues/140

for vue 3

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

and config i18n manually

examples from vue-i18n-next:

Example with using Composable API

Example with using Legacy API

Examples Directory

if you want install vue add i18n change

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

to

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

and for typescript project add vue-i18n.d.ts file and the content is

declare module "vue-i18n"

for vue 3 i install npm install --save vue-i18n@next instead of vue add i18n

like image 74
H.Azizkhani Avatar answered Nov 14 '22 02:11

H.Azizkhani