Skip to content

bug NG SERVE : fails when adding new angular material imports #19080

@rdelormeCHS

Description

@rdelormeCHS

Reproduction

I see this issue reported else where and the reports are closed, but I don' think it is.
I'm somewhat new to angular and first time reporting something, so bare with me if i don't do this 100% right. I have a new project I just created. out of the box, ng new installed angular/cdk, material, animations hammerjs, bootstrap to get started.

starting to import angular material modules.

Steps to reproduce:

  1. I run ng serve. things run fine at first, no components added yet.
  2. Now, to so app.module.ts -> import any angular material component, doesn't matter which one.
  • add the import at the top.
  • add the module to the ngModule-> Imports.
  1. go to app.component -> add a declaration. I just copy and paste the example for material web site for testing.
  2. ng serve gives following error:

ERROR in node_modules/@angular/material/card/card-module.d.ts:8:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.

This likely means that the library (@angular/material/card) which declares MatCardModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

8 export declare class MatCardModule {
                       ~~~~~~~~~~~~~
  1. Kill ng serve.
  2. Run ng build
  3. run ng serve -> now it works.

There is something internally going wrong. Usually, I can go to @ngModule->Imports and start typing a module name and use the VS COde auto-import plugin but the intellisense is not showing an material components ->only after adding the import at the top of the file, then it shows the one component in intellisense.

I have another project on my same machine. The version of the @angular stuff is one revision earlier. It all works fine as expected. I recall seeing this error in that project at the beginning too. I just don't have any idea how I got rid of it, but realistically, this shouldn't happen in a clean out of the box project using all angular components.

Expected Behavior

What behavior were you expecting to see?

I am expecting that ng serve works as expected -> on the fly compile successfully.

Actual Behavior

required to kill ng serve, and do ng build and restart ng serve.

Environment

  • Angular:
    {
    "name": "my-new-app",
    "version": "0.0.0",
    "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod --aot",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
    "@angular/animations": "^9.0.7",
    "@angular/cdk": "^9.2.1",
    "@angular/common": "~9.0.3",
    "@angular/compiler": "~9.0.3",
    "@angular/core": "~9.0.3",
    "@angular/forms": "~9.0.3",
    "@angular/material": "^9.2.1",
    "@angular/platform-browser": "~9.0.3",
    "@angular/platform-browser-dynamic": "~9.0.3",
    "@angular/router": "~9.0.3",
    "bootstrap": "^4.4.1",
    "hammerjs": "^2.0.8",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
    },
    "devDependencies": {
    "@angular-devkit/build-angular": "~0.900.4",
    "@angular/cli": "~9.0.4",
    "@angular/compiler-cli": "~9.0.3",
    "@angular/language-service": "~9.0.3",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.7.5"
    }
    }

  • Browser(s): Chrome, but N/A for this issue.

  • Operating System (e.g. Windows, macOS, Ubuntu):
    Windows 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions