简体   繁体   English

ng 命令返回“未知错误:错误:无效的 JSON 字符:0:0 处的“a””

[英]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为我的 Windows 10 64 位机器安装了 Node JS 版本 12.19.0,npm 默认版本为 6.14.8

Installed angular cli using the command npm install -g @angular/cli使用命令npm install -g @angular/cli

When i try any ng command from the command prompt it returns the error message当我从命令提示符尝试任何 ng 命令时,它会返回错误消息

Unknown Error : Error : Invalid JSON character: "a" at 0:0未知错误:错误:无效的 JSON 字符:0:0 处的“a”

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在运行 ng serve 时遵循链接无效 JSON 字符中的解决方案,并使用 Notepad++ 将 angular.json 文件编码转换为 UTF-8 并在环境变量中包含 ng 路径,即 C:\\Users<username>\\AppData\\漫游\\npm\\node_modules@angular\\cli\\bin

I have an angular.json file in my users folder and it starts with angular.json text.我的用户文件夹中有一个 angular.json 文件,它以angular.json文本开头。 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.我有 npm 和 nodejs 路径变量。 Nothing seems to fix this issue.似乎没有什么可以解决这个问题。

Deleted the angular.json in my users/ folder and that did the trick for me.删除了我的 users/ 文件夹中的angular.json ,这对我angular.json As Abedin.Zhuniqi suggested, i think you cannot have more than one angular.json files in your system正如 Abedin.Zhuniqi 建议的那样,我认为您的系统中不能有多个angular.json文件

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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