Skip to content

Error showed up while run the command ng generate module about #10880

Closed

Description

@leoliuasia

Versions

λ ng --version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.1
Node: 9.8.0
OS: win32 x64
Angular: 6.0.2
... animations, 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
@angular/cli                      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 new nebular-demo
  • cd nebular-demo
  • ng serve
  • ng generate module about

Observed behavior

λ ng generate module about
Unexpected token ] in JSON at position 720

Same error when run command ng generate component about

What is happening?

Activity

  1. phl3x0r commented on May 16, 2018

    @phl3x0r

    Perhaps an issue with the encoding of angular.json, it's just a guess based on other related issues.
    Try converting your angular.json file to utf-8 without BOM and see if that helps.
    And of course verify that angular.json contains only valid json :-)

  2. leoliuasia commented on May 17, 2018

    @leoliuasia
    Author

    Thanks for the reply! The encoding of angular.json is the utf-8 without BOM. And It is a valid json file. Actually I haven't done anything with the angular.json. It is just a new project generated using angular-cli.

  3. hitokiri commented on May 20, 2018

    @hitokiri

    I same problem

    Angular CLI: 6.0.2
    Node: 8.11.2
    OS: linux x64
    Angular: 6.0.2
    ... animations, cdk, cli, common, compiler, compiler-cli, core
    ... forms, http, language-service, material, 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.2
    @ngtools/webpack                  6.0.1
    @schematics/angular               0.6.2
    @schematics/update                0.6.2
    rxjs                              6.1.0
    typescript                        2.7.2
    webpack                           4.6.0
    

    display error
    Unexpected token ] in JSON at position 1337

  4. xlxAciDxlx commented on May 20, 2018

    @xlxAciDxlx
         _                      _                 ____ _     ___
        / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
       / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
      / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
     /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                    |___/
    
    
    Angular CLI: 6.0.3
    Node: 9.10.0
    OS: win32 x64
    Angular: 6.0.2
    ... animations, common, compiler, compiler-cli, core, forms
    ... http, language-service, platform-browser
    ... platform-browser-dynamic, router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.6.3
    @angular-devkit/build-angular     0.6.3
    @angular-devkit/build-optimizer   0.6.3
    @angular-devkit/core              0.6.3
    @angular-devkit/schematics        0.6.3
    @angular/cli                      6.0.3
    @ngtools/webpack                  6.0.3
    @schematics/angular               0.6.3
    @schematics/update                0.6.3
    rxjs                              6.1.0
    typescript                        2.7.2
    webpack                           4.8.3
    

    Same thing here. I'd be able to fix it myself if it at least said what file the error was found in.. I've checked every JSON file I can find (including angular.json), and all of them are valid.

    Calling: ng g c components/index
    Error: Unexpected token } in JSON at position 1333

  5. leoliuasia commented on May 21, 2018

    @leoliuasia
    Author

    It looks like not just me had the problem, I think it may be an encoding problem, but not sure where it is.

  6. xlxAciDxlx commented on May 21, 2018

    @xlxAciDxlx

    It looks like not just me had the problem

    When I searched for the issue (to see if it already existed), yours was the first of many that had come up.

    but not sure where it is

    Yeah, same issue here. Running a linter and tsc all work fine, it just seems to be generating things that's broken for me.

  7. xlxAciDxlx commented on May 21, 2018

    @xlxAciDxlx

    Alright, my issue's fixed. It appears the error's caused by something being wrong in angular.json - I must've missed it when manually looking through my files. I threw it in JSONLint and it immediately threw an error. You can obviously do this for other files, but I'm going to assume this error is mainly caused by angular.json.

  8. leoliuasia commented on May 22, 2018

    @leoliuasia
    Author

    I’ll try it to see if it works for me.

  9. leoliuasia commented on May 22, 2018

    @leoliuasia
    Author

    I have found the problem. check the angular.json file.

    "assets": [
                  "src/favicon.ico",
                  "src/assets",
                ],
                "styles": [
                  "src/styles.css",
                  "./node_modules/bootstrap/dist/css/bootstrap.css",
                  "./node_modules/@nebular/theme/styles/prebuilt/default.css",
                ],
    

    just remove the comma after "src/assets" and "...default.css"
    like below:

    "assets": [
                  "src/favicon.ico",
                  "src/assets"
                ],
                "styles": [
                  "src/styles.css",
                  "./node_modules/bootstrap/dist/css/bootstrap.css",
                  "./node_modules/@nebular/theme/styles/prebuilt/default.css"
                ],
    

    then will fix the problem.
    Somehow if the comma is in js code it will work. But not here.

    Thanks to @xlxAciDxlx !

  10. hitokiri commented on May 22, 2018

    @hitokiri

    I do not have the commas, which you mention and I keep giving the error.

  11. xlxAciDxlx commented on May 22, 2018

    @xlxAciDxlx

    @leoliuasia Glad you were able to get it fixed :D

    @hitokiri Did you try running your angular.json through JSONLint? Even if you don't have the commas, could be some other minor error messing it up.

  12. leoliuasia commented on May 23, 2018

    @leoliuasia
    Author

    @hitokiri May be you need to check the other positons that not same as my. Or just use the JSONLint tool mentioned by @xlxAciDxlx

  13. added 2 commits that reference this issue on Jun 6, 2018
    27f27be
    00b7f01
  14. added 3 commits that reference this issue on Jun 8, 2018
    a222f6b
    815352c
    960041d
  15. added 2 commits that reference this issue on Jun 11, 2018
    b7bff64
    69e3fa7
  16. shinks21 commented on Jun 16, 2018

    @shinks21

    @leoliuasia thank you! I had the same error and running my angular.json through json found the issue. There was a comment in the file that I had to remove. ng generate component works now.

  17. kaziupir commented on Nov 11, 2018

    @kaziupir

    I had comma in tsconfig.json, so try to check all json files in json lint.

  18. angular-automatic-lock-bot commented on Sep 8, 2019

    @angular-automatic-lock-bot

    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.

  19. locked and limited conversation to collaborators on Sep 8, 2019
  20. added a commit that references this issue on May 29, 2026
    614d120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions