Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set property 'locale' of undefined #173

Closed
willin opened this issue Dec 27, 2018 · 5 comments · Fixed by #178
Closed

Cannot set property 'locale' of undefined #173

willin opened this issue Dec 27, 2018 · 5 comments · Fixed by #178

Comments

@willin
Copy link

willin commented Dec 27, 2018

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)
@michaelwnyc
Copy link

Same issue as in #166

My Nuxt config is:

[
      'nuxt-i18n',
      {
        defaultLocale: 'zh',
        detectBrowserLanguage: {
          useCookie: true,
          cookieKey: 'i18n_redirected'
        },
        locales: [
          {
            code: 'en',
            iso: 'en-US',
            file: 'en-US.js',
            name: 'EN'
          },
          {
            code: 'zh',
            iso: 'zh-CN',
            file: 'zh-CN.js',
            name: '中'
          }
        ],
        lazy: true,
        langDir: 'lang/',
        rootRedirect: null,
        strategy: 'prefix_except_default'
      }
    ]

I'm deploying with nuxt generate. Suspecting that Nuxt hasn't initialized Vuex successfully so that state is returning undefined instead of a function: https://nuxtjs.org/guide/vuex-store#modules-mode

priezz added a commit to priezz/nuxt-i18n that referenced this issue Jan 2, 2019
@priezz priezz mentioned this issue Jan 6, 2019
paulgv pushed a commit that referenced this issue Jan 14, 2019
* Fix state not defined without SSR.

* Add preserveState option.

* Add docs.

Fixes #173
@pixlforge
Copy link

So funny enough, this issue started happening after I installed Vue devtools beta 5 on Chrome. Went right away after I removed the extension.

@sustained
Copy link

I have this issue too when clicking "load state" in Vue Devtools.

@rchl
Copy link
Collaborator

rchl commented Aug 28, 2019

@sustained Can you also check with v6.0.2 just to establish whether it's a recent regression or not?

Also, where is load state button in Vue Devtools? I couldn't find that one but if I click Force refresh then whole Vue devtools kinda crash (stop reacting).

@sustained
Copy link

image

image

image

[sustained@aurora nuxt-dynamic-markdown-example-project]$ cat node_modules/nuxt-i18n/package.json | grep '"version":'
  "version": "6.0.2"

@rchl

farnabaz pushed a commit to farnabaz/i18n-module that referenced this issue Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants