Skip to content

Cannot set property 'locale' of undefined #173

@willin

Description

@willin

Version

v5.3.0

Reproduction link

Steps to reproduce

when development mode it's ok, but when built and deployed it shown error.

What is expected ?

works properly

What is actually happening?

c6b25ed7d1e571a9b85f.js:1 [nuxt] Error while initializing app TypeError: Cannot set property 'locale' of undefined
    at f.<anonymous> (c6b25ed7d1e571a9b85f.js:1)
    at 33b42310abd05a803713.js:2
    at 33b42310abd05a803713.js:2
    at Array.forEach (<anonymous>)
    at 33b42310abd05a803713.js:2
    at f._withCommit (33b42310abd05a803713.js:2)
    at f.commit (33b42310abd05a803713.js:2)
    at f.commit (33b42310abd05a803713.js:2)
    at o.commit (33b42310abd05a803713.js:2)
    at f.setLocale (c6b25ed7d1e571a9b85f.js:1)

source code: https://github.com/nuxt-community/nuxt-i18n/blob/master/src/plugins/main.js#L41

wx20181230-005037 2x

state got undefined

Additional comments?

Config:

  modules: [
    ['nuxt-i18n', {
      locales: [
        { name: '简体中文', code: 'zh', iso: 'zh-CN', file: 'zh.js' },
        { name: 'English', code: 'en', iso: 'en-US', file: 'en.js' }
      ],
      lazy: true,
      langDir: 'locales/',
      strategy: 'prefix',
      defaultLocale: 'zh',
      detectBrowserLanguage: {
        useCookie: true,
        cookieKey: 'i18n_redirected'
      },
      rootRedirect: 'en',
      vueI18n: {
        fallbackLocale: 'en'
      }
    }]
  ],

deployed files: https://dev.tencent.com/u/willin/p/willin.wang/git/tree/master

  • ROOT
  • 404.html
  • zh/ folder
  • en/ folder
This bug report is available on Nuxt community (#c183)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions