【问题标题】:ng command returns "Unknown Error : Error : Invalid JSON character: "a" at 0:0"ng 命令返回“未知错误:错误:无效的 JSON 字符:“a”在 0:0”
【发布时间】:2020-10-26 20:27:19
【问题描述】:

为我的 Windows 10 64 位机器安装了 Node JS 版本 12.19.0,npm 默认版本是 6.14.8

使用命令npm install -g @angular/cli安装了angular cli

当我从命令提示符尝试任何 ng 命令时,它会返回错误消息

未知错误:错误:无效的 JSON 字符:0:0 处的“a”

我遵循链接Invalid JSON character when running ng serve 中的解决方案并使用Notepad++ 将angular.json 文件编码转换为UTF-8,并在环境变量中包含ng 的路径,即C:\Users\AppData\Roaming \npm\node_modules@angular\cli\bin

我的用户文件夹中有一个 angular.json 文件,它以 angular.json 文本开头。我知道问题出在那个文件中,但我不知道如何解决它。

我有 npm 和 nodejs 路径变量。似乎没有什么可以解决这个问题。

【问题讨论】:

    标签: node.js angular npm angular-cli


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      删除了我的 users/ 文件夹中的 angular.json ,这对我有用。正如 Abedin.Zhuniqi 建议的那样,我认为您的系统中不能有多个 angular.json 文件

      【讨论】:

      • 不,正如 Angular 的官方文档告诉我们的那样。 The application builder uses the webpack build tool, with default configuration options specified in the workspace configuration file (angular.json) or with a named alternative configuration.
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-17
      • 2016-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-27
      相关资源
      最近更新 更多