I\'m brand new to Angular 2 and attempting to follow along with a video tutorial I found. Despite following all of the steps, Angular just won\'t work; I get the following e
With Angular 5, I solved a similar problem by ugrading to @angular/cli
1.6.1 from 1.5.5:
"devDependencies": {
"@angular/cli": "1.6.1"
}
During ng serve
the error I got was:
ERROR in Error: No NgModule metadata found for 'AppModule'.
at NgModuleResolver.resolve (/path/to/project/app/node_modules/@angular/compiler/bundles/compiler.umd.js:20247:23)
I had the same problem and couldn't solve it after reading all the above answers. Then I noticed that an extra comma in declarations was creating a problem. Removed it, problem solved.
@NgModule({
imports: [
PagesRoutingModule,
ThemeModule,
DashboardModule,
],
declarations: [
...PAGES_COMPONENTS,
**,**
],
})
I finally found the solution.
npm remove webpack
npm install --save-dev @angular/cli@latest
after successfully test app, it will work :)
If not then follow below steps:
npm cache clean --force
npm install
npm install --save-dev @angular/cli@latest
Note: If failed, try step 4 again. It will work.
I'll give you few suggestions.Remove all these as mentioned below
1)<script src="polyfills.bundle.js"></script>(index.html) //<<<===not sure as Angular2.0 final version doesn't require this.
2)platform.bootstrapModule(App); (main.ts)
3)import { NgModule } from '@angular/core'; (app.ts)
In my case, I had defined a couple of (private) static methods in one of my components and was using them in the same component.
I had the same issue and I resolved it by closing the editor i.e. Visual Studio Code
, started it again, run ng serve
and it worked.