question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement vuex-i18n together with Nuxt.js (SyntaxError Unexpected token export)

See original GitHub issue

I have difficulties to implement vuex-i18n together with Nuxt.js (modules mode). Now I get the error message: SyntaxError Unexpected token export

Can someone help please or direct me into the right direction or provide the base setup structure to implement vuex-i18n together with Nuxt.js? A small outline example perhaps?

So far I put the code into folder plugins. As far as I understand our Nuxt.js store operates in “modules mode”, but I’m uncertain how to setup the store/i18n.js because I’m new to this Nuxt.js/Vue(x)

    ├─ plugins
    │   ├─ i18n.js
  …
    ├─ store
    │   ├─ index.js
    │   ├─ i18n.js

The plugins/i18n.js:

// plugins/i18n.js
import Vue from 'vue'
import Vuex from 'vuex'
// load and register the vuex i18n module
import vuexI18n from 'vuex-i18n'

import { english } from '~/locales/en.json'
import { german } from '~/locales/de.json'

const doDebug = process.env.NODE_ENV !== 'production'

const store = new Vuex.Store({
  strict: doDebug
})

Vue.use(
  vuexI18n.plugin,
  store,
  {
    onTranslationNotFound: function (locale, key) {
      console.warn(`vuex-i18n :: Key '${key}' not found for locale '${locale}'`)
    }
  })

// register the locales
Vue.i18n.add('en', english)
Vue.i18n.add('de', german)

// Set the start locale to use
Vue.i18n.set('de')
Vue.i18n.fallback('en')

export default store

Any help? Thank you very much.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tikiatuacommented, Nov 14, 2017

Hi @infinite-dao,

Please try using import vuexI18n from 'vuex-i18n/dist/vuex-i18n.umd.js'; to load the vuex-i18n plugin.

We changed the default file to the es-version, which is probably why you are seeing the token error message.

0reactions
tikiatuacommented, Jan 10, 2018

Thank you for the feedback. This means we broke something with 1.10. I will take a look at the differences between the versions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nuxt Error: Syntax Unexpected token export after installation
I just checked your issue and it happens when you use element UI with Nuxt. Update your Nuxt configuration like this(Andrew Answer):
Read more >
How to fix Nuxt.js unexpected token export error - YouTube
Setting up Nuxt. js is a pretty straightforward process but I hit at least one snag. Here's how I got around an issue...
Read more >
Vue/Nuxt Unexpected token export | Vue Forums
When I try to import the "DashboardLayoutPlugin" per the Documentation, I get an error of "Syntax Error: Unexpected token export".
Read more >
export default { ^^^^^^ syntaxerror: unexpected token 'export'
The "Uncaught SyntaxError Unexpected token 'export'" occurs for 2 main reasons: Using the ES6 Module syntax in a Node.js application without type to...
Read more >
vuejs/vue - Gitter
@hezhongfeng You have to use normal link for that purpose. ... under ios 7-8 i got SyntaxError: Unexpected token ',' but ios >...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found