2

I'm running into the following error when starting serve on Angular CLI.

Parsing angular-cli.json failed. Please make sure your angular-cli.json is valid JSON.
Error: SyntaxError: Unexpected token in JSON at position 0

I've checked the json file with a checker served as a tip in other questions I found here and it comes up fully ok. I'm using Visual studio RC 2017 to edit the JSON to add bootstrap as a style. Commenting out the added style also results in the same error. So it seems as soon as VS2017 touches the JSON it goes wrong.

Any of you experienced this, or have a solution?

Thanks in advance!

Matthias

edit: link to json file. When I use notepad to edit json file it works fine. It's a VS2017 issue I think. json file

4
  • Link added in post. Commented Feb 26, 2017 at 15:11
  • JSON seems to be fine. Include verifiable code so that we can take a look? Commented Feb 26, 2017 at 15:14
  • Did some more research and found interesting info, it's connected to UTF8 and BOM. No real solution provided: github.com/angular/angular-cli/issues/4503 Commented Feb 26, 2017 at 15:24
  • @MatthiasTT I just had this exact issue and @JoeVella's answer solved it for me. Commented Apr 3, 2017 at 23:50

2 Answers 2

3

For Visual Studio 2017 Community and angular cli, I solved this by turning off Auto-detect UTF-8 encoding without signature and Follow project coding conventions.

Got to: Tools | Options | Text Editor | General: then uncheck Auto-detect UTF-8 encoding without signature and Follow project coding conventions.

If your file was modified by VS before doing this, copy a new one from another untouched cli project.

Sign up to request clarification or add additional context in comments.

2 Comments

What do you mean by Follow project coding conventions? I am getting same error but solution will not work
My solution to this has always been to open the file in Notepad++ and change the encoding that way. That way you are 100% certain to have the correct encoding every time.
0

Copy the contents of angular-cli.json, then delete the file. Re-create this file in file explorer as a simple text document. Don't forget to change extension to json. It is funny- Visual Studio doesn't know how to create a .json file..

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.