服务和构建命令的角度CLI问题

时间:2019-06-11 08:05:14

标签: angular typescript npm

{
    "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
    "version": 1,
    "newProjectRoot": "projects",
    "projects": {
        "demoProject": {
            "root": "",
            "sourceRoot": "src",
            "projectType": "application",
            "prefix": "app",
            "schematics": {},
            "architect": {
                "build": {
                    "builder": "@angular-devkit/build-angular:browser",
                    "options": {
                        "outputPath": "dist/hrms",
                        "index": "src/index.html",
                        "main": "src/main.ts",
                        "polyfills": "src/polyfills.ts",
                        "tsConfig": "src/tsconfig.app.json",
                        "assets": [
                            "src/favicon.ico",
                            "src/assets",
                            "src/main"
                        ],
                        "styles": [
                            "node_modules/bootstrap/dist/css/bootstrap.min.css",
                            "node_modules/ion-rangeslider/css/ion.rangeSlider.css",
                            "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
                            "node_modules/ion-rangeslider/css/ion.rangeSlider.skinFlat.css",
                            "node_modules/ngx-toastr/toastr.css",
                            "src/styles.css",
                            "src/main.css"
                        ],
                        "scripts": [
                            "node_modules/jquery/dist/jquery.min.js",
                            "node_modules/bootstrap/dist/js/bootstrap.min.js",
                            "node_modules/ion-rangeslider/js/ion.rangeSlider.min.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": "hrms:build"
                    },
                    "configurations": {
                        "production": {
                            "browserTarget": "hrms:build:production"
                        }
                    }
                },
                "extract-i18n": {
                    "builder": "@angular-devkit/build-angular:extract-i18n",
                    "options": {
                        "browserTarget": "hrms: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/**"
                        ]
                    }
                }
            }
        },
        "hrms-e2e": {
            "root": "e2e/",
            "projectType": "application",
            "architect": {
                "e2e": {
                    "builder": "@angular-devkit/build-angular:protractor",
                    "options": {
                        "protractorConfig": "e2e/protractor.conf.js",
                        "devServerTarget": "hrms:serve"
                    },
                    "configurations": {
                        "production": {
                            "devServerTarget": "hrms:serve:production"
                        }
                    }
                },
                "lint": {
                    "builder": "@angular-devkit/build-angular:tslint",
                    "options": {
                        "tsConfig": "e2e/tsconfig.e2e.json",
                        "exclude": [
                            "**/node_modules/**"
                        ]
                    }
                }
            }
        }
    },
    "defaultProject": "hrms"
}

{
  "name": "demoProject",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng build && node ./bin/www",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.0.0",
    "@angular/cdk": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@ng-bootstrap/ng-bootstrap": "^1.1.2",
    "amazing-time-picker": "^1.5.3",
    "angular-2-dropdown-multiselect": "^1.8.1",
    "angular-datatables": "^6.0.0",
    "angular2-datetimepicker": "^1.1.1",
    "angular2-multiselect-dropdown": "^2.9.0",
    "angular4-datepicker": "^1.0.1",
    "body-parser": "^1.18.3",
    "bootstrap": "^4.3.1",
    "chart.js": "^2.5.0",
    "core-js": "^2.4.1",
    "crypto-js": "^3.1.9-1",
    "datatables.net": "^1.10.16",
    "datatables.net-dt": "^1.10.16",
    "express": "^4.16.3",
    "jquery": "^3.4.1",
    "json-validation": "^1.0.4",
    "moment": "^2.22.2",
    "morgan": "^1.9.1",
    "mysql": "^2.15.0",
    "ng-circle-progress": "^1.0.0",
    "ng-multiselect-dropdown": "^0.2.0",
    "ng-select": "^1.0.0-rc.5",
    "ng2-date-picker": "^2.10.2",
    "ng2-file-upload": "^1.3.0",
    "ng2-ion-range-slider": "^2.0.0",
    "ng2-select": "^2.0.0",
    "ng4-loading-spinner": "^1.2.3",
    "ngx-bar-rating": "^1.1.0",
    "ngx-bootstrap": "^2.0.5",
    "ngx-loading": "^1.0.14",
    "ngx-spinner": "^2.0.0",
    "ngx-toastr": "^8.1.0",
    "request": "^2.88.0",
    "request-promise": "^4.2.2",
    "rxjs": "^5.5.6",
    "serve-favicon": "^2.5.0",
    "timepicker.js": "^2.4.0",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.800.2",
    "@angular/cli": "~6.0.5",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/datatables.net": "^1.10.13",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/jquery": "^3.3.5",
    "@types/node": "^6.0.116",
    "codelyzer": "^4.4.3",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^2.0.5",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.1",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
}

我无法使用任何ngbuild之类的serve命令,它给我下面的错误,我无法解决。

  

架构验证失败,出现以下错误:数据路径   “ .builders ['app-shell']”应具有必需的属性“ class”。错误:   架构验证失败,出现以下错误:数据路径   “ .builders ['app-shell']”应具有必需的属性“ class”。       在MergeMapSubscriber._registry.compile.pipe.operators_1.concatMap.validatorResult中   [作为项目]   (/home/divx/Documents/projects/project_source_code/todoapplication/node_modules/@angular-devkit/core/src/workspace/workspace.js:173:42)

https://i.stack.imgur.com/yN1zf.png

1 个答案:

答案 0 :(得分:1)

您最近是否升级了Angular版本?看来CLI无法验证您的angular.json文件中的架构,该文件最近随着Angular 8的发布而发生了变化。

您是否可以共享文件顶部定义的angular.json或至少schema