Error installing plugin with message 'Error: Line 16: Unexpected token let'
See original GitHub issueI’ve read other issues and believe this error is similar but sufficiently different from other reported cases, including this one here: https://github.com/kazupon/vue-cli-plugin-i18n/issues/9,
Running vue add i18n
fails to complete (the generator???) on a real project that I am building. If I generate just a blank project with minimal options as the default then the plugin installs OK; however, this isn’t my reality becuase I am working on a Production app. The real noteworthy differences I can discern between an empty project and mine, is that my real project has a few other components such as vuex, vuetify, and typescript and completed vue components – that I need to localize.
Hope you can help. package.txt
I’ve attached my package.json (as package.txt since package.json was blocked) in case it helps pinpoint the versions of other plugins I am using. I’d appreciate your input on what I am doing wrong or a fix.
My environment: OSX Mojave, Node 10.3.0, Error log:
$ vue add i18n
📦 Installing vue-cli-plugin-i18n...
+ vue-cli-plugin-i18n@0.5.1
added 5 packages from 3 contributors and audited 40202 packages in 15.011s
found 6 vulnerabilities (1 low, 4 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
✔ Successfully installed plugin: vue-cli-plugin-i18n
? The locale of project localization. en
? The fallback locale of project localization. en
? The directory where store localization messages of project. It's stored under `src` directory. locales
? Enable locale messages in Single file components ? No
🚀 Invoking generator for vue-cli-plugin-i18n...
ERROR Error: Line 16: Unexpected token let
Error: Line 16: Unexpected token let
at ErrorHandler.constructError (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:5012:22)
at ErrorHandler.createError (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:5028:27)
at Parser.unexpectedTokenError (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:1985:39)
at Parser.throwUnexpectedToken (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:1995:21)
at Parser.consumeSemicolon (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:2297:23)
at Parser.parseLabelledStatement (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:4029:19)
at Parser.parseStatement (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:4122:97)
at Parser.parseStatementListItem (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:3393:31)
at Parser.parseScript (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:4723:29)
at Object.parse (/Users/calvinnguyen/.nvm/versions/node/v10.3.0/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:122:61)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8 (1 by maintainers)
Top GitHub Comments
It appears that during initialization the plugin will need to write to
vue.config.js
. This issue is likely caused by that config file not being empty. Try backup the existing content ofvue.config.js
and empty that file, if the initialization is successful you can put the original content back in. Hope this would help.Hello! I also experienced this error. Here’s the console log:
I looked into the files that the plugin modifies and found out that my
main.ts
’s line 32 contains the code below. I temporarily commented it out, ranvue add i18n
again, and then it worked.It fails because Esprima encountered a line on my
main.ts
file that contains Typescript specific code, i.e. type cast syntax.