Implement vuex-i18n together with Nuxt.js (SyntaxError Unexpected token export)
See original GitHub issueI 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:
- Created 6 years ago
- Comments:9 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Thank you for the feedback. This means we broke something with 1.10. I will take a look at the differences between the versions.