Unable to add @angular/material

471 views
Skip to first unread message

gopal krishna

unread,
Jan 23, 2020, 2:43:42 PM1/23/20
to Angular and AngularJS discussion
Hi All,

Am using angular 8 and trying to install angular material using ng add @angular/material

am getting below error :

Unable to fetch package metadata: Cannot read property 'startsWith' of null

can someone tell me what all I should be looking at,
my hello world PGM runs fine in angular 8 but unable to install material on the machine (windows)


package.json 
{
  "name""hello-world",
  "version""0.0.0",
  "scripts": {
    "ng""ng",
    "start""ng serve",
    "build""ng build",
    "test""ng test",
    "lint""ng lint",
    "e2e""ng e2e"
  },
  "private"true,
  "dependencies": {
    "@angular/animations""~8.2.14",
    "@angular/common""~8.2.14",
    "@angular/compiler""~8.2.14",
    "@angular/core""~8.2.14",
    "@angular/forms""~8.2.14",
    "@angular/platform-browser""~8.2.14",
    "@angular/platform-browser-dynamic""~8.2.14",
    "@angular/router""~8.2.14",
    "@coreui/angular""^2.7.2",
    "@coreui/coreui""^2.1.16",
    "@coreui/icons""^1.0.0",
    "rxjs""~6.4.0",
    "tslib""^1.10.0",
    "zone.js""~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular""~0.803.21",
    "@angular/cli""~8.3.21",
    "@angular/compiler-cli""~8.2.14",
    "@angular/language-service""~8.2.14",
    "@types/node""~8.9.4",
    "@types/jasmine""~3.3.8",
    "@types/jasminewd2""~2.0.3",
    "codelyzer""^5.0.0",
    "jasmine-core""~3.4.0",
    "jasmine-spec-reporter""~4.2.1",
    "karma""~4.1.0",
    "karma-chrome-launcher""~2.2.0",
    "karma-coverage-istanbul-reporter""~2.0.1",
    "karma-jasmine""~2.0.1",
    "karma-jasmine-html-reporter""^1.4.0",
    "protractor""~5.4.0",
    "ts-node""~7.0.0",
    "tslint""~5.15.0",
    "typescript""~3.5.3"
  }
}

manish pamnani

unread,
Jan 30, 2020, 12:49:16 PM1/30/20
to Angular and AngularJS discussion
What steps are you using to add angular maetrial to your project?

The prooper way to add the angular material project to your project are:-

- Install angular material via ng add @angular/material
- Import the Angular Material COmponent that you need in app.module.ts:

  imports: [
    BrowserModule,
    NoopAnimationsModule,
    MatAutocompleteModule,
    MatButtonModule,
    MatCheckboxModule,
    MatButtonToggleModule,
    MatPseudoCheckboxModule,
    MatDatepickerModule,
    MatFormFieldModule,
    MatInputModule,
    MatRadioModule,
    MatSelectModule,
    MatSliderModule,
    MatSlideToggleModule
  ]

- Use the components in the HTML file where you want to use it

  <mat-checkbox>Check me!</mat-checkbox>

  Hope this helps.
Reply all
Reply to author
Forward
0 new messages