components: Schematics: ng add throws startTag error

Bug:

Installing material using schematic with custom theme option throws error in Terminal.

Error: Cannot read property 'startTag' of undefined

What is the expected behavior?

Material added with custom theme option configures app with material

What is the current behavior?

An error is thrown in Terminal.

What are the steps to reproduce?

  1. Create a new app

    ng new test-app --prefix=tst --style=scss

  2. Install material

    yarn add @angular/material

  3. Run schematic

    ng add @angular/material --theme=custom

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

MacBook Pro, Sierra 10.13.5 Chrome Version 67.0.3396.99

"@angular/core": "^6.0.3", // all angular deps
 "@angular/cdk": "^6.3.2",
 "@angular/material": "^6.3.2",
 "@angular/cli": "~6.0.8"
"typescript": "~2.7.2",

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 22
  • Comments: 35 (1 by maintainers)

Commits related to this issue

Most upvoted comments

I used ng add @angular/material@6.2.1 it worked , it seems ng add @angular/material@6.3.1 have some problem that is latest one

If you don’t want to downgrade material and retain @angular/material@6.3.1, you can make the same edit in node_modules as in this PR just before you run the schematics.

I don’t have node_modules/@angular/cli/schematics/utils in my app what am I doing wrong, I have run ng new test-app and this folder above does not exist

The fix by jerryorta-dev worked very well. You really need to modify the file html.js from the dir node_modules/@angular/cli/schematics/utils if you really need to use the latest version of Angular Material.