在Angular 4中创建新组件时出错

时间:2018-07-19 07:09:33

标签: angular angular-components

我尝试使用以下命令创建一个名为signup-form的新组件:

ng generate component signup-form / ng g component signup-form

我收到此错误:

  

意外令牌/ JSON中的位置1154

我不知道我从哪个json文件中收到此错误。

下面是angular-cli.json的内容。

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ylet": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {

      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ylet",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "C:/ylet/node_modules/office-ui-fabric/dist/css/fabric.css",
              "C:/ylet/node_modules/office-ui-fabric/dist/css/fabric.components.css",
              "C:/ylet/node_modules/office-ui-fabric/dist/css/fabric.min.css",
              "C:/ylet/node_modules/office-ui-fabric/dist/css/fabric.components.min.css",
              "C:/ylet/src/styles.css"
            ],
            "scripts": [
              "C:/ylet/node_modules/office-ui-fabric/dist/js/fabric.min.js",
              "C:/ylet/node_modules/ng-office-ui-fabric/ngOfficeUiFabric.js",

            ]
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ylet:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ylet:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ylet:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css"
            ],
            "scripts": [

            ],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "ylet-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "ylet:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "ylet:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "ylet"
}

2 个答案:

答案 0 :(得分:1)

编辑

scripts块(第二行)中,您有逗号结尾,请删除它并保存文件,然后尝试生成ng。

"scripts": [
   "C:/ylet/node_modules/office-ui-fabric/dist/js/fabric.min.js",
   "C:/ylet/node_modules/ng-office-ui-fabric/ngOfficeUiFabric.js",
]

答案 1 :(得分:0)

仅使用“ ng g component signup-form