Open calirails opened 5 years ago
Similar but likely related error:
> vue add i18n
📦 Installing vue-cli-plugin-i18n...
+ vue-cli-plugin-i18n@0.5.1
added 6 packages from 7 contributors and audited 41987 packages in 12.35s
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` directory. locales
? Enable locale messages in Single file components ? Yes
🚀 Invoking generator for vue-cli-plugin-i18n...
ERROR SyntaxError: Unexpected token / in JSON at position 53
SyntaxError: Unexpected token / in JSON at position 53
at JSON.parse (<anonymous>)
at api.postProcessFiles.files (/Users/dids/<project>/node_modules/vue-cli-plugin-i18n/generator/index.js:137:27)
at Generator.resolveFiles (/Users/dids/.nvm/versions/node/v8.14.0/lib/node_modules/@vue/cli/lib/Generator.js:219:13)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
related #19
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.
The same problem. Relating to previous comment: I don't know how can I find problem file, because call stack doesn't include name or path of the problem file.
I think I get something same
vue add i18n
📦 Installing vue-cli-plugin-i18n...
yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.12: The platform "linux" is incompatible with this module.
info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ vue-cli-plugin-i18n@1.0.1
info All dependencies
└─ vue-cli-plugin-i18n@1.0.1
Done in 3.06s.
✔ 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 SyntaxError: Unexpected token / in JSON at position 366
SyntaxError: Unexpected token / in JSON at position 366
at JSON.parse (<anonymous>)
at /home/jeff/gitclones/android/myproject/node_modules/vue-cli-plugin-i18n/generator/index.js:138:27
at Generator.resolveFiles (/home/jeff/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:299:13)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async Generator.generate (/home/jeff/.config/yarn/global/node_modules/@vue/cli/lib/Generator.js:175:5)
at async runGenerator (/home/jeff/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:109:3)
at async invoke (/home/jeff/.config/yarn/global/node_modules/@vue/cli/lib/invoke.js:90:3)
267:tarkhil@over.ru:/home/tarkhil/mlb > vue add i18n
WARN There are uncommitted changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes
📦 Installing vue-cli-plugin-i18n...
+ vue-cli-plugin-i18n@1.0.1
added 28 packages from 15 contributors in 33.343s
78 packages are looking for funding
run `npm fund` for details
✔ Successfully installed plugin: vue-cli-plugin-i18n
? The locale of project localization. ru
? 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 ? Yes
🚀 Invoking generator for vue-cli-plugin-i18n...
ERROR Error: Line 18: Unexpected token ?
Error: Line 18: 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)
Looks like it's exploding at random with Vue 3
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.
@wolfmon that works. Just revert all custom changes in vue.config.js
to default, install i18n, then apply your changes back.
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: