Reputation: 19150
Despite following the advice here -- TypeScript error in Angular2 code: Cannot find name 'module', I'm still getting this error. I'm using Angular 5 and npm 6.9.0. I'm trying to work through this tutorial here -- https://medium.freecodecamp.org/learn-how-to-create-your-first-angular-app-in-20-min-146201d9b5a7 .
I have this at the top of my ./src/app/app.component.ts file
import { Component,trigger,animate,style,transition,keyframes } from '@angular/core';
import { FormsModule } from '@angular/forms';
@NgModule({
imports: [
BrowserModule,
FormsModule //<----------make sure you have added this.
],
})
But when I run my application I get the error
localhost:todo-app davea$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2019-05-17T17:06:29.377Z
Hash: e9b5158cd1cb6d5685c7
Time: 2561ms
chunk {inline} inline.bundle.js (inline) 3.85 kB [entry] [rendered]
chunk {main} main.bundle.js (main) 2.91 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js (polyfills) 577 bytes [initial] [rendered]
chunk {styles} styles.bundle.js (styles) 41.6 kB [initial] [rendered]
chunk {vendor} vendor.bundle.js (vendor) 867 kB [initial] [rendered]
ERROR in src/app/app.component.ts(4,2): error TS2552: Cannot find name 'NgModule'. Did you mean 'module'?
src/app/app.component.ts(6,14): error TS2304: Cannot find name 'BrowserModule'.
What else do I need to do to get NgModule recognized?
Upvotes: 5
Views: 7739
Reputation: 2422
This error, Cannot find name 'NgModule'
, is due to not having imported NgModule
from @angular/core
. Adding that to the first line will solve the issue.
Upvotes: 8