vue-i18n-extract icon indicating copy to clipboard operation
vue-i18n-extract copied to clipboard

[vue-i18n-extract] SyntaxError: Unexpected token 'export'

Open Compizfox opened this issue 1 year ago • 0 comments

I'm trying to use vue-i18n-extract and vue-i18n v9 for Vue 3, but get the following error when trying to run it:

npm run vue-i18n-extract

> [email protected] vue-i18n-extract
> vue-i18n-extract report --vueFiles './src/**/*.?(js|vue|ts)' --languageFiles './src/i18n/*.?(ts|js|mjs)'

[vue-i18n-extract] SyntaxError: Unexpected token 'export'
    at /home/lars/src/Huispage/frontend/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:199:47
    at Array.map (<anonymous>)
    at readLanguageFiles (/home/lars/src/Huispage/frontend/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:187:24)
    at createI18NReport (/home/lars/src/Huispage/frontend/node_modules/vue-i18n-extract/dist/vue-i18n-extract.umd.js:339:27)
    at CAC.<anonymous> (/home/lars/src/Huispage/frontend/node_modules/vue-i18n-extract/bin/vue-i18n-extract.js:47:5)
    at CAC.runMatchedCommand (/home/lars/src/Huispage/frontend/node_modules/cac/dist/index.js:614:34)
    at CAC.parse (/home/lars/src/Huispage/frontend/node_modules/cac/dist/index.js:541:12)
    at Object.<anonymous> (/home/lars/src/Huispage/frontend/node_modules/vue-i18n-extract/bin/vue-i18n-extract.js:56:5)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)

In installed it as explained in the README, with the following in package.json:

  "scripts": {
    "vue-i18n-extract": "vue-i18n-extract report --vueFiles './src/**/*.?(js|vue|ts)' --languageFiles './src/i18n/*.?(ts|js)'"
  }

My locale message file looks like this:

export default {
	'en': {
		'key': 'Message',
        },
}

Does vue-i18n-extract not support vue-i18n v9 for Vue 3 or am I doing something wrong? I found some old threads describing the same issue (I think) but it's not clear to me how to fix it.

Compizfox avatar Dec 26 '23 15:12 Compizfox