i18n: Cannot read property 'headers' of undefined after Nuxt Generate

Hello, another error appears after run npm run generate.

Steps:

  1. try create a new nuxt project like: vue init vuetifyjs/nuxt my-project then npm install or yarn

  2. install this nuxt-i18n plugin: yarn add nuxt-i18n then add some configuration to nuxt.config.js.

  3. npm run dev works fine.

  4. npm run generate shows many errors: like this:

 ROUTE  /en/pages/about

  TypeError: Cannot read property 'headers' of undefined

  - server-bundle.js:5621 module.exports.__webpack_exports__.default
    server-bundle.js:5621:43

  - server-bundle.js:1902 promisify
    server-bundle.js:1902:15

  - server-bundle.js:1883 middlewareSeries
    server-bundle.js:1883:10

  - server-bundle.js:5465 module.exports.__webpack_exports__.default
    server-bundle.js:5465:81
  1. im sure that the errors from this plugin, i have disabled it from nuxt.config.js, and re run npm run generate and everything works fine.

  2. is this plugin works with npm run generate ?

any help!

<div align="right">This question is available on Nuxt.js community (#c43)</div>

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 31

Commits related to this issue

Most upvoted comments

I could solve this problem to check req value.

if(req && req.headers && req.headers.cookie){
  // your code
}