【问题标题】:Init my Angular 6 project fails : schematics does not works初始化我的 Angular 6 项目失败:原理图不起作用
【发布时间】:2019-02-18 03:40:48
【问题描述】:

我正在尝试创建一个新的 Angular 项目并添加 @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

有什么想法吗?谢谢!

【问题讨论】:

  • 留意这个github issue登录Angular CLI repo
  • 到那时你可以使用this workaround
  • 谢谢@PankajParkar。那么现在,对我来说安装稳定版 Angular 的最佳方式是什么?
  • 我已经看到了这个解决方法,但我没有在我的项目中找到 projects.YOUR-APP-NAME.targets
  • 检查我的更新答案

标签: angular angular-cli angular-schematics


【解决方案1】:

这个issue已经登陆github了,大家可以关注#12230。

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

改变

projects.YOUR-APP-NAME.targets

收件人

projects.YOUR-APP-NAME.architect

在下面的解释中查看angular.json中需要进行的确切更改

angular.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`
        ....
      },
      ...
  }
}

【讨论】:

    猜你喜欢
    • 2020-08-23
    • 1970-01-01
    • 2015-06-20
    • 2016-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多