【问题标题】:Angular app fails to run and displays invalid config errorAngular 应用程序无法运行并显示无效的配置错误
【发布时间】:2018-02-25 23:17:59
【问题描述】:

我正在从 Angular cli 启动器构建我的 Angular 应用程序。 下面的错误提示了该问题。

C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\@angular\cli\models\config\config.js:76 抛出新的 InvalidConfigError(common_tags_1.stripIndent ^ InvalidConfigError: Parsing 'C:\Users\Afropepe\Desktop\development\buy-ticket.angular-cli.json' 失败的。确保文件是有效的 JSON。错误:意外的令牌] in 位置 535 处的 JSON 在 InvalidConfigError (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\@angular\cli\models\config\config.js:11:9) 在 Function.fromConfigPath (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\@angular\cli\models\config\config.js:76:19) 在 Function.fromProject (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\@angular\cli\models\config.js:88:46) 在对象。 (C:\Users\Afropepe\Desktop\development\buy-ticket\node_modules\@angular\cli\commands\build.js:7:35) 在 Module._compile (module.js:570:32) 在 Object.Module._extensions..js (module.js:579:10) 在 Module.load (module.js:487:32) 在 tryModuleLoad (module.js:446:12) 在 Function.Module._load (module.js:438:3) 在 Module.require (module.js:497:17)

【问题讨论】:

  • 用项目文件夹更新帖子或分享一个github repo链接
  • 我想通过重新安装打字稿解决了这个问题,我想我解决了这个问题。

标签: javascript angular


【解决方案1】:

angular-cli.json 内容:

//"index": "index.html", “main”:“main.ts”, “polyfills”:“polyfills.ts”, "test": "test.ts",

在 .angular-cli.json/ angular-cli.json 中只需 删除 ////"index": "index.html",因为它不会被视为注释并抛出一些例外。

正确的输出:

  "main": "main.ts",
  "polyfills": "polyfills.ts",
  "test": "test.ts",

【讨论】:

    【解决方案2】:

    我有同样的错误,通过更换新的 angular-cli.json 并重新配置解决。

    【讨论】:

    • 如何删除现有的 Angular clis json??
    【解决方案3】:

    请确保您的名为“.angular-cli.json”的文件包含 JSON 格式,在我的情况下,我在 JSON 文件中添加了一些 cmets,即使在 VS 编译时,这也是无效的

    • “资产”:[“资产”],

    • //"index": "myindexfile.html",

    • "main": "main.ts",

      请确保您的文件具有正确的 JSON 格式

    我得到的错误如下:

    • \@angular\cli\models\config\config.js:89 抛出新的 InvalidConfigError(common_tags_1.stripIndent ` ^

    【讨论】:

      【解决方案4】:

      尝试在脚本文件中导入 angular-cli.json 时出现一些错误

       "../node_modules/tether/dist/js/tether.min.js" 
      

      之后

      "../node_modules/bootstrap/dist/js/bootstrap.min.js"
      

      所以当一个库需要在它之前包含另一个库时,可能会出现此问题。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-11-17
        • 2022-01-01
        • 1970-01-01
        • 2015-11-03
        • 2015-05-05
        • 1970-01-01
        • 2016-10-05
        相关资源
        最近更新 更多