Skip to content

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

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
rafidka opened this issue Jun 12, 2018 · 3 comments · Fixed by #15026
Closed

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

rafidka opened this issue Jun 12, 2018 · 3 comments · Fixed by #15026

Comments

@rafidka
Copy link

rafidka commented Jun 12, 2018

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.

@rafidka
Copy link
Author

rafidka commented Jun 12, 2018

Also, I just noticed #5610 which seems to have been addressed, which suggests comment should be allowed and the CLI should not complain about / characters in angular.json. Or am I missing something?

@filipesilva filipesilva added freq1: low Only reported by a handful of users who observe it rarely severity2: inconvenient labels Jul 19, 2018
@ngbot ngbot bot added this to the needsTriage milestone Jan 24, 2019
@sam-s4s
Copy link

sam-s4s commented Mar 3, 2019

This is very frustrating...

Invalid JSON character: "" at 0:0.
Error: Invalid JSON character: "" at 0:0.

Ummm... which file?

If I look at the error through a different text output, it reads:

Invalid JSON character: "" at 0:0.
Error: Invalid JSON character: "" at 0:0.

So I'm gonna have to open all the json files with a hex editor I guess... :/

@clydin clydin added freq2: medium type: bug/fix and removed freq1: low Only reported by a handful of users who observe it rarely labels May 13, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 13, 2019
kyliau pushed a commit that referenced this issue Jul 9, 2019
kyliau pushed a commit that referenced this issue Jul 9, 2019
@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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants