isabille
isabille

Reputation: 33

'FormsModule' does not appear to be an NgModule class

I am trying to import the FormsModule but i get this error 'FormsModule' does not appear to be an NgModule class. here is my code

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; // Add this import

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule 
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

and my package.json this

"dependencies": {
    "@angular/animations": "~10.1.3",
    "@angular/common": "^10.1.6",
    "@angular/compiler": "^10.1.6",
    "@angular/core": "^10.1.6",
    "@angular/fire": "^6.1.0",
    "@angular/forms": "^10.1.6",
    "@angular/platform-browser": "~10.1.3",
    "@angular/platform-browser-dynamic": "~10.1.3",
    "@angular/router": "~10.1.3",
    "firebase": "^8.0.1",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.10.2"
  }

I did search to similar question here but didnt help me i did try to unistall forms and install again also didnt work

Upvotes: 1

Views: 27

Answers (1)

Naren Murali
Naren Murali

Reputation: 57986

Add this to the package.json scripts object.

"scripts": {
  ...
  "postinstall": "ngcc",
  ...
}

So that the packages are all compatible with Ivy Engine (default engine for angular 10).

Angular 10 Libraries and IVY/ngcc Compatibility

Upvotes: 1

Related Questions