首页 > 解决方案 > 初始化我的 Angular 6 项目失败:原理图不起作用

问题描述

我正在尝试创建一个新的角度项目并添加@angular/material原理图。但它失败并出现此错误:

Installed packages for tooling via npm.
Your project is not using the default configuration for build and test. The Angular Material schematics can only be used with the default configuration

为了创建我的项目并从头开始添加材料原理图,我执行了以下命令:

nvm use v10.10.0
npm install -g @angular/cli # Version is : @angular/cli@6.2.1
npm install -g @angular-devkit/schematics-cli # Version is : @angular-devkit/schematics-cli@0.8.1
ng new a
cd a
ng add @angular/material # -> Error here

有任何想法吗 ?谢谢 !

标签: angularangular-cliangular-schematics

解决方案


此问题已登录 github,您可以使用#12230密切关注。

但在那之前它已经解决了,你可以使用下面的解决方法,你必须稍微调整angular.json一下

改变

projects.YOUR-APP-NAME.targets

projects.YOUR-APP-NAME.architect

查找下面的说明以查看需要在哪里进行更改angular.json

角.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "sample-bank": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "targets": { //< -- change `targets` to `architect`
        ....
      },
      ...
  }
}

推荐阅读