Skip to content

ng-add: schematic breaks if a lower version of CDK is already installed #18020

@Splaktar

Description

@Splaktar

Reproduction

https://github.com/Splaktar/test-blog/tree/angular-material-schematic-failure

Steps to reproduce:

  1. ng add @angular/material@next
? Choose a prebuilt theme name, or "custom" for a custom theme: Custom
? Set up global Angular Material typography styles? Yes
? Set up browser animations for Angular Material? Yes
UPDATE package.json (1574 bytes)
✔ Packages installed successfully.
schematics_2.getProjectIndexFiles is not a function

Expected Behavior

Successful schematic execution.

Actual Behavior

Error: schematics_2.getProjectIndexFiles is not a function

Plus project left in a bad/invalid state after failure:

  "dependencies": {
    "@angular/animations": "~9.0.0-rc.7",
    "@angular/cdk": "~8.2.3",
    "@angular/common": "~9.0.0-rc.7",
    "@angular/compiler": "~9.0.0-rc.7",
    "@angular/core": "~9.0.0-rc.7",
    "@angular/forms": "~9.0.0-rc.7",
    "@angular/material": "^9.0.0-rc.6",

@angular/cdk wasn't installed prior to this, but somehow it got installed at ~8.2.3 while @angular/material is rc.6.

In one case, BrowserAnimationsModule was added, in another run it was not.

The custom styles don't get generated into styles.scss.

Environment

Angular CLI: 9.0.0-rc.7
Node: 12.13.0
OS: darwin x64

Angular: 9.0.0-rc.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.7
@angular-devkit/build-angular     0.900.0-rc.7
@angular-devkit/build-optimizer   0.900.0-rc.7
@angular-devkit/build-webpack     0.900.0-rc.7
@angular-devkit/core              9.0.0-rc.7
@angular-devkit/schematics        9.0.0-rc.7
@angular/cdk                      8.2.3
@angular/material                 9.0.0-rc.6
@ngtools/webpack                  9.0.0-rc.7
@schematics/angular               9.0.0-rc.7
@schematics/update                0.900.0-rc.7
rxjs                              6.5.3
typescript                        3.6.4
webpack                           4.41.2

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions