Skip to content

Error message when angular.json is invalid is not very descriptive #11204

Closed
@rafidka

Description

@rafidka

Bug Report or Feature Request (mark with an x)

- [ ] bug report
- [x] feature request

Area

- [ ] devkit
- [ ] schematics

Versions

Output of ng --version:

Angular CLI: 6.0.8
Node: 9.8.0
OS: darwin x64
Angular: 6.0.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cli                      6.0.8
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.0
typescript                        2.7.2
webpack                           4.8.3

Repro steps

  1. Create a new project: ng new test-angular
  2. Edit angular.json and add some invalid input, for example add a comment to the first line.
  3. Use the CLI to add a new module ng generate module New

The log given by the failure

Unexpected token / in JSON at position 0

Desired functionality

  1. The message should be a little bit more descriptive. It is currently a bit difficult to understand the problem, and for new comers, it might seem there is a problem with the package instead of angular.json. Here are some issues which shows other users also had confusion about this:

#10843
#10938
#11103

  1. Replace absolute position with line and line position. It doesn't help much if I get position 1277 and have to find out which line this is.

Example: Found an unexpected token / in angular.json in line 123 character 45.

This is much more descriptive and clearly tells the user that there is a problem in his/her angular.json file and the line where the error is found.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions