错误:位置652中的JSON中的意外令牌]

时间:2019-06-04 14:16:44

标签: angular

我的项目在我尝试运行ng serve时出现了错误

  

错误:位置652中的JSON中的意外令牌]       在Function.fromConfigPath(C:\ Users \ Administrateur \ Desktop \ CustemerManagementFront \ node_modules @ angular \ cli \ models \ config \ config.js:89:19)       在Function.fromProject(C:\ Users \ Administrateur \ Desktop \ CustemerManagementFront \ node_modules @ angular \ cli \ models \ config.js:67:46)       在对象。 (C:\ Users \ Administrateur \ Desktop \ CustemerManagementFront \ node_modules @ angular \ cli \ commands \ build.js:10:3​​5)       在Module._compile(内部/模块/cjs/loader.js:701:30)       在Object.Module._extensions..js(内部/模块/cjs/loader.js:712:10)       在Module.load(internal / modules / cjs / loader.js:600:32)       在tryModuleLoad(内部/模块/cjs/loader.js:539:12)       在Function.Module._load(内部/模块/cjs/loader.js:531:3)       在Module.require(internal / modules / cjs / loader.js:637:17)       在要求时(internal / modules / cjs / helpers.js:22:18)

angular-cli.json文件

  {
      "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
      "project": {
        "name": "custemer-management"
      },
      "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets",
            "favicon.ico"
          ],
          "index": "index.html",
          "main": "main.ts",
          "polyfills": "polyfills.ts",
          "test": "test.ts",
          "tsconfig": "tsconfig.app.json",
          "testTsconfig": "tsconfig.spec.json",
          "prefix": "app",
          "styles": [
            "styles.css",
            "src/../../node_modules/bootstrap/dist/css/bootstrap.css",
            "../node_modules/ng2-toastr/bundles/ng2-toastr.min.css",

          ],
          "scripts": [
            "../node_modules/jquery/dist/jquery.js",
          ],
          "environmentSource": "environments/environment.ts",
          "environments": {
            "dev": "environments/environment.ts",
            "prod": "environments/environment.prod.ts"
          }
        }
      ],
      "e2e": {
        "protractor": {
          "config": "./protractor.conf.js"
        }
      },
      "lint": [
        {
          "project": "src/tsconfig.app.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "src/tsconfig.spec.json",
          "exclude": "**/node_modules/**"
        },
        {
          "project": "e2e/tsconfig.e2e.json",
          "exclude": "**/node_modules/**"
        }
      ],
      "test": {
        "karma": {
          "config": "./karma.conf.js"
        }
      },
      "defaults": {
        "styleExt": "css",
        "component": {}
      }
    }

2 个答案:

答案 0 :(得分:0)

您必须删除"../node_modules/ng2-toastr/bundles/ng2-toastr.min.css","../node_modules/jquery/dist/jquery.js",末尾的逗号。

JSON不允许。

答案 1 :(得分:0)

正如@pindev所说,上述行末尾的逗号是问题所在,因为它们导致无效的JSON格式。

如果您自己修改文件,则应确保其具有有效的JSON格式。在线上有许多JSON验证程序,它们会告诉您格式是否有效,如果无效,它会告诉您错误在哪里。