Skip to content

Angular CLI: 6.0.1 - Unexpected token } in JSON at position 2686 #10843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tjaussoin-luna opened this issue May 14, 2018 · 14 comments
Closed

Angular CLI: 6.0.1 - Unexpected token } in JSON at position 2686 #10843

tjaussoin-luna opened this issue May 14, 2018 · 14 comments

Comments

@tjaussoin-luna
Copy link

Hi, when I try to create a component, I have this error :
Unexpected token } in JSON at position 2686

Versions

Angular CLI: 6.0.1
Node: 10.0.0
OS: darwin x64
Angular: 6.0.0
... animations, common, compiler-cli, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@angular/cdk                      6.0.1
@angular/cli                      6.0.1
@angular/compiler                 6.0.1
@angular/flex-layout              6.0.0-beta.15
@angular/material                 6.0.1
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

ng g c listsample
Unexpected token } in JSON at position 2686

@ToniJM
Copy link

ToniJM commented May 15, 2018

Same error here but in another line:

Unexpected token } in JSON at position 1075

Angular CLI: 6.0.1
Node: 8.11.1
OS: win32 x64
Angular: 6.0.1
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
@angular-devkit/architect         0.6.1
@angular-devkit/build-angular     0.6.1
@angular-devkit/build-optimizer   0.6.1
@angular-devkit/core              0.6.1
@angular-devkit/schematics        0.6.1
@ngtools/webpack                  6.0.1
@schematics/angular               0.6.1
@schematics/update                0.6.1
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

@ToniJM
Copy link

ToniJM commented May 16, 2018

I've updated Node to 10.1 and it's working...

Angular CLI: 6.0.1
Node: 10.1.0
OS: win32 x64
Angular:
...

Package                      Versio
-----------------------------------
@angular-devkit/architect    0.6.1
@angular-devkit/core         0.6.1
@angular-devkit/schematics   0.6.1
@schematics/angular          0.6.1
@schematics/update           0.6.1
rxjs                         6.1.0
typescript                   2.7.2

@tjaussoin-luna
Copy link
Author

Updated as well to Node 10.1.0 as suggested by @ToniJM
Same problem on my side ;(
Unexpected token } in JSON at position 2686

Angular CLI: 6.0.1
Node: 10.1.0

@briangullo
Copy link

When you call ng generate, it reads the angular.json file in your project. I had a similar issue, except mine was "Unexpected token /". I had commented out portions of the json file. The CLI did not like the my use of "//", so I had to remove the commented out sections, and it started working fine after that. So comb through your angular.json file, you probably have some malformed code in it.

@tjaussoin-luna
Copy link
Author

@briangullo you're right. Thanks!
My JSON had this issue (the comma after "error", last line...).

   "en": {
          "aot": true,
          "outputPath": "dist/myapp-en/",
          "i18nFile": "src/locale/messages.en.xlf",
          "i18nFormat": "xlf",
          "i18nLocale": "en",
          "i18nMissingTranslation": "error", // REMOVE COMMA HERE
        }

@leonardopaiva
Copy link

@briangullo same problem here, thanks.

@jbeckton
Copy link

Unexpected token ] in JSON at position 434

I pasted my angular.json file into a json validator and it clean. not sure where to look now.

@shivpratapjnv80
Copy link

shivpratapjnv80 commented Aug 29, 2018

Use
These Command

  1. ng update
  2. ng update@ angular/cli

@jtal
Copy link

jtal commented Sep 19, 2018

I received this error as well. "Unexpected token }" or "]" probably means you put a comma after the last element. The error message doesnt provide the file name or line number but I'm guessing position is characters from start of file. I just opened angular.json in vim and the culprit was highlighted.

Also, come on JSON specification, is that comma hurting anyone? ;)

@m4r71n85
Copy link

delete package-lock.json

@michelepatrassi
Copy link

JSON is malformed, you can easily spot the error at https://jsonlint.com/

@michaeltarleton
Copy link

In my case I had a trailing ',' after one of my style imports in angular.json

@rajeshdas85
Copy link

i used this command it resolved my issue
ng update@ angular/cli

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests