首页 文章

ng生成组件给出“意外令牌[在位置800的json中”

提问于
浏览
-3

当我在位置800的json中运行“ng generate component”“意外令牌”时 . 当我输入服务时,窗口会持续运行 . 有什么帮助吗? PS E:\ angulartutorial \ my-first-app> ng生成关于Unexpected token的组件]在JSON的800位和当我运行服务时

1 回答

  • 0

    只是为了搜索者的利益回答这个问题(并在评论中确认一个声明):

    对我来说,答案是 angular.json 中的无效字符(虽然其他人可能会在 angular-cli.jsonpackage.json 中找到问题,对我来说罪魁祸首是 angular.json ) .

    Visual Studio Code中打开文件有助于识别错误(另一位编辑认为它是有效的) .

    在我的情况下,原因是我在json中发表了评论 .

    例如 . 在angular.json中,此源提供错误:

    "scripts": [
                    /* boostrap.bundle includes popper.js */
                    "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
                ]
    

    错误:位置888处的JSON中出现意外的令牌/

    但删除评论,它可以工作,例如

    "scripts": [
                    "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
                ]
    

相关问题