2

我正在尝试在 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"
  }
}

我正在运行以下命令: Angular CLI:6.2.1 节点:10.9.0 操作系统:darwin x64 Angular:6.1.7

4

1 回答 1

0

几周后,重做整个 Angular 项目对象,我最终不得不将 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
于 2018-11-10T16:51:07.080 回答