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.

Error installing plugin with message 'Error: Line 16: Unexpected token let'

See original GitHub issue

I’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:open
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
wolfmoncommented, May 21, 2021

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 of vue.config.js and empty that file, if the initialization is successful you can put the original content back in. Hope this would help.

2reactions
bmdelacruzcommented, Feb 19, 2019

Hello! I also experienced this error. Here’s the console log:

📦  Installing vue-cli-plugin-i18n...

+ vue-cli-plugin-i18n@0.5.1
updated 1 package and audited 26257 packages in 41.819s
found 0 vulnerabilities

✔  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` direc
tory. locales
? Enable locale messages in Single file components ? No

🚀  Invoking generator for vue-cli-plugin-i18n...
 ERROR  Error: Line 32: Unexpected token <
Error: Line 32: Unexpected token <
    at ErrorHandler.constructError (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:5012:22)
    at ErrorHandler.createError (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:5028:27)
    at Parser.unexpectedTokenError (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:1985:39)
    at Parser.throwUnexpectedToken (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:1995:21)
    at Parser.parsePrimaryExpression (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:2366:38)
    at Parser.inheritCoverGrammar (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:2285:37)
    at Parser.parseLeftHandSideExpressionAllowCall (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:2899:26)
    at Parser.inheritCoverGrammar (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:2285:37)
    at Parser.parseUpdateExpression (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:3004:26)
    at Parser.parseUnaryExpression (/usr/local/lib/node_modules/@vue/cli/node_modules/esprima/dist/esprima.js:3048:26)

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, ran vue add i18n again, and then it worked.

(<any>window).mockController = mockController; // DEBUG

It fails because Esprima encountered a line on my main.ts file that contains Typescript specific code, i.e. type cast syntax.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line 16: Unexpected token let' · Issue #28 · intlify/vue-cli ...
It appears that during initialization the plugin will need to write to vue.config.js . This issue is likely caused by that config file...
Read more >
ESLint Parsing error: Unexpected token - Stack Overflow
The solution is to have ESLint parsed by a compatible parser, i.e @babel/eslint-parser or babel-eslint for babel version below v7. just add: " ......
Read more >
How to Fix the "Parse Error: Syntax Error, Unexpected" in ...
It's not difficult to fix, but it can sometimes take time to track it down. The steps are simple: If you've added code,...
Read more >
ESLint: "Parsing error: Unexpected token" in Visual Studio Code
The solution. Unexpected token errors are caused by incompatibilities in your parser options and the code you're writing. In this case, I'm ...
Read more >
How to Fix the Syntax Error in WordPress - WPBeginner
After installing the FTP program, connect it to your website and go to the theme file that needs editing. In case you forgot...
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