问题
I am getting following error when running ng serve...
PS F:\Projects\RecipeApp> ng serve
Invalid JSON character: "\"" at 76:13.
Error: Invalid JSON character: "\"" at 76:13.
at _token (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:63:19)
at _readArray (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:316:9)
at _readValue (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:561:22)
at _readProperty (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:398:19)
at _readObject (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:431:30)
at _readValue (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:564:22)
at _readProperty (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:398:19)
at _readObject (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:431:30)
at _readValue (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:564:22)
at _readProperty (F:\Projects\RecipeApp\node_modules\@angular-devkit\core\src\json\parser.js:398:19)
I am using angular version 6
回答1:
Check your Angular.json.
It seems that this config file is not correct.
Update for clarification:
A misplaced "/" in the angular.json
will create exactly that kind of error.
回答2:
In my case the problem was Visual Studio 2017 adding UTF-8 BOM characters to angular.json after I edited the file.
Permanent solution for Visual Studio and Angular CLI was to open the file once and save as UTF-8 without signature
- Go to
File
->Save As
.
- Then on Save button click on triangle and click
Save with Encoding...
.
- From Encodings dropdown select
UTF-8 Without signature
-> ClickOK
.
回答3:
Open the file in Notepad++ and change the encoding to UTF-8 then save it will work for sure :)
回答4:
Looks like you've added a path in the angular.json file with "\" instead of "/".
回答5:
Its mainly due to the syntax error in angular.json file. make sure there is a comma (,) in every end of the previous line. and also check the slash ( / and \ ) in path. use "/" instead of "\".
回答6:
I just had the same issue as described while using the "ng g c" command. The issue was that I forgot a comma (,) while adding a second style-sheet to the angular.json file.
Hope this helps someone, Vlad
回答7:
Make sure angular.json encoding in UTF-8
not UTF-8-BOM
.
来源:https://stackoverflow.com/questions/51517046/invalid-json-character-when-running-ng-serve