1

2020欧洲杯时间表I implemented my vue application with i18n and it worked all fine yesterday. But when I tried to start my application today I got the error which you can see in the title. I can give the following stack trace:

TypeError: Cannot read property 'i18n' of undefined
    at module.exports (..\node_modules\vue-cli-plugin-i18n\index.js:4:49)
    at ..\node_modules\@vue\cli-service\lib\Service.js:93:7
    at Array.forEach (<anonymous>)
    at Service.init (..\node_modules\@vue\cli-service\lib\Service.js:91:18)
    at Service.run (..\node_modules\@vue\cli-service\lib\Service.js:230:10)
    at Object.<anonymous> (..\node_modules\@vue\cli-service\bin\vue-cli-service.js:36:9)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <Projectname>@0.1.0 serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <Projectname>@0.1.0 serve script.

(I took out my paths and replaced them with "..")

2020欧洲杯时间表I really can't explain, why I get this error now. Because yesterday I also had to restart the server and it worked all fine..

I also took out every line of code in which I use something like

$i18n.locale

(Except for the routing and code in the index.js etc.) But that didn't work for me too.

And I deleted the node_module folder as well and installed everything again but this didn't work.

2020欧洲杯时间表If you need any information please tell me.

  • Does this help? – ssc-hrep3 May 24 at 0:51
  • sadly not, I'm already passing the i18n instance and it still doesn't work.. :( – Lars May 24 at 15:04
  • Okay so I found out, that the problem is in the vue-cli-plugin-i18n\index.js file. There is a constant called "enableInSFC" which should have the following value: "options.pluginOptions.i18n". This throws an error because i18n is undefined. When I comment that code out and If I also comment out the further use of this constant and try to start the server, it works all fine. Even the translations are still working, I can still translate my whole application.. But since the code resets, if I use npm install or npm install vue-i18n, my solution isn't really good. – Lars May 24 at 15:41
  • Do you use incompatible versions of Vue CLI and Vue i18n? Try to update all dependencies, reinstall and try again. Sounds like a dependency problem. Try also to reproduce that problem in a separate project where you include vue i18n. Then copy the relevant code lines from your current project to that demo project and try again. – ssc-hrep3 May 24 at 16:24
  • I'm pretty new to npm and vue, how do I update all dependencies? sorry.. – Lars May 24 at 18:47
1

2020欧洲杯时间表I'm pretty new to vue.js but I'm facing a similar issue (same stack trace). Here is what I have found hoping it can help you :

Adding a file vue.config.js at the root of the project with :

module.exports = {
  pluginOptions: {
    i18n: {
      locale: 'fr',
      fallbackLocale: 'en',
      localeDir: 'assets/locales',
      enableInSFC: true
    }
  }
}

2020欧洲杯时间表seems to resolve the compilation issue (no clue if it's the right solution, I'm still searching).

What I have done to find this is vue add i182020欧洲杯时间表 then remove file/modification one by one util the compilation error came back.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our , and

Not the answer you're looking for? Browse other questions tagged or ask your own question.