无法运行ng generate @ angular / material:material-nav

时间:2018-09-07 03:44:01

标签: angular angular-cli angular-material-6

我正在尝试在Angular 6项目上设置Angular Material。但是,尝试运行时:

ng generate @angular/material:material-nav --project=ui-project

我收到以下错误消息:

Cannot read property 'replace' of undefined

这是我的package.json

{
  "name": "ui-project",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/schematics": "^0.8.1",
    "@angular/cdk": "^6.2.1",
    "@angular/common": "^6.1.7",
    "@angular/compiler": "^6.1.7",
    "@angular/core": "^6.1.7",
    "@angular/forms": "^6.1.7",
    "@angular/http": "^6.1.7",
    "@angular/material": "^6.4.7",
    "@angular/platform-browser": "^6.1.7",
    "@angular/platform-browser-dynamic": "^6.1.7",
    "@angular/router": "^6.1.7",
    "core-js": "^2.4.1",
    "help": "^3.0.2",
    "parse5": "^5.1.0",
    "rxjs": "^6.3.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.8.26",
    "@angular/animations": "^6.0.0"
  },
  "devDependencies": {
    "@types/jasmine": "2.8.8",
    "@types/node": "^10.9.4",
    "codelyzer": "~4.4.4",
    "jasmine-core": "3.2.1",
    "jasmine-spec-reporter": "4.2.1",
    "karma": "3.0.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.6.0",
    "protractor": "~5.4.0",
    "ts-node": "7.0.1",
    "tslint": "^5.11.0",
    "typescript": "~3.0.3",
    "webpack": "^4.17.2"
  }
}

我正在运行以下内容: 角CLI:6.2.1 节点:10.9.0 操作系统:Darwin x64 角度:6.1.7

1 个答案:

答案 0 :(得分:0)

几周后,并重做了整个有角度的项目对象,我最终不得不将cli升级到版本7。使用ng update -all命令将所有依赖关系更新到正确的版本,这样就可以正常工作。

这是结果

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.10.2
@angular-devkit/core         7.0.2
@angular-devkit/schematics   7.0.2
@schematics/angular          7.0.2
@schematics/update           0.10.2
rxjs                         6.3.3
typescript                   3.1.3