简体   繁体   中英

ng command returns "Unknown Error : Error : Invalid JSON character: "a" at 0:0"

Installed Node JS version 12.19.0 for my Windows 10 64 bit machine and the npm default version was 6.14.8

Installed angular cli using the command npm install -g @angular/cli

When i try any ng command from the command prompt it returns the error message

Unknown Error : Error : Invalid JSON character: "a" at 0:0

i followed the solution in the link Invalid JSON character when running ng serve and converted the angular.json file encoding to UTF-8 using Notepad++ and having the path of ng in the environment variables ie, C:\\Users<username>\\AppData\\Roaming\\npm\\node_modules@angular\\cli\\bin

I have an angular.json file in my users folder and it starts with angular.json text. I know the issue is in that file , but i don't know how to fix it.

I have the npm and nodejs path variables in place. Nothing seems to fix this issue.

Deleted the angular.json in my users/ folder and that did the trick for me. As Abedin.Zhuniqi suggested, i think you cannot have more than one angular.json files in your system

你不能有两个 angular.json 因为当项目有它自己的 angular.json 更改它的名称或删除它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM