@ngtools/webpack complainning about not an NgModule
using @ngtools/webpack 1.1.7
tried both @angular/compiler-cli 2.1.x and 2.2.0
import { NgModule, Component } from '@angular/core';
@Component({
selector: 'app',
template: '<h1>hello world</h1>',
styles: []
})
class AppComponent {}
@NgModule({
declarations: [AppComponent],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
Error: AppModule is not an NgModule
at AotPlugin.getNgModuleMetadata (/var/build/node_modules/@ngtools/webpack/src/plugin.js:297:19)
at AotPlugin._processNgModule (/var/build/node_modules/@ngtools/webpack/src/plugin.js:241:42)
at /var/build/node_modules/@ngtools/webpack/src/plugin.js:217:39
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
Done in 7.29s.
@zakdances downgrading all packages to 2.2.3 didn't work for me..:( Which packages did you downgraded to 2.2.3 exactly?? Thanks
@DutchKevv make sure you downgrade router to 3.2.3 or so as well.
Thanks Jess, but didn't get it to work..
Using these packages ->
"@angular/common": "2.2.3", "@angular/compiler": "2.2.3", "@angular/core": "2.2.3", "@angular/forms": "2.2.3", "@angular/http": "2.2.3", "@angular/platform-browser": "2.2.3", "@angular/platform-browser-dynamic": "2.2.3", "@angular/router": "3.2.3", "@ngrx/core": "^1.2.0", "@ngrx/effects": "^2.0.0", "@ngrx/store": "2.2.1", "@ngrx/store-devtools": "^3.2.1", "@ngrx/store-log-monitor": "^3.0.2",
Probably just wait until Typescript and Angular are friends again on final releases.. But can't build production now :(
@DutchKevv try to rm -rf npm_modules && npm cache clean before installation.
I think this issue is related to [email protected] and tsc-wrapped as dhardtke and jessezhang91 said.
In https://github.com/angular/angular/blob/2.2.x/tools/@angular/tsc-wrapped/src/collector.ts#L254 , which collects metadata from app.module.ts ,
case ts.SyntaxKind.ClassDeclaration:
const classDeclaration = <ts.ClassDeclaration>node;
if (classDeclaration.name) {
const className = classDeclaration.name.text;
if (node.flags & ts.NodeFlags.Export) { // this is false always!
if (classDeclaration.decorators) {
if (!metadata) metadata = {};
metadata[className] = classMetadataOf(classDeclaration);
}
}
}
this code works only if node.flags & ts.NodeFlags.Export g.t. 0. But in https://github.com/Microsoft/TypeScript/blob/v2.1.1/src/compiler/types.ts#L400 , there is no export enum named Export. (In [email protected] ts.NodeFlags has the Export value. see https://github.com/Microsoft/TypeScript/blob/v2.0.10/src/compiler/types.ts#L395 )
I'm getting the same error using TypeScript 2.0.10, trying to link modules from 1 app into another. Both are generated using angular-cli version 1.0.0-beta.22.
Yep same problem here with "typescript": "2.0.10" and "angular-cli": "1.0.0-beta.22-1" any solutions ?
not working even with typescript 2.0.10, using @ngtools/webpack 1.1.9
0% compilingError: AppModule is not an NgModule
at AotPlugin.getNgModuleMetadata (/Users/antony/Documents/Code/Web/angular-webpack-starter/node_modules/@ngtools/webpack/src/plugin.js:332:19)
at AotPlugin._processNgModule (/Users/antony/Documents/Code/Web/angular-webpack-starter/node_modules/@ngtools/webpack/src/plugin.js:271:42)
at /Users/antony/Documents/Code/Web/angular-webpack-starter/node_modules/@ngtools/webpack/src/plugin.js:242:39
reproduction repo, just update the package.json for ngtools and angular packages
fixed, following updates from https://github.com/angular/angular-cli/commit/45d5154
@tarlepp @antonybudianto Workaround: Specify the precise dependency versions in the package.json.
@timosalm already did, it's breaking after @ngtools 1.1.6
Dear Angular team, maybe it's not obvious, but it's a very dangerous bug - when users can't build production build, it means development of their projects is stopped. And it's not so easy to explain to product owners why it's impossible (for now) to implement minor changes (even if task is just edit text). And this bug is not even labeled. Please, give some attention to this bug. I understand you have a lot of tasks, but it's really important bug.
Here're my dependencies. They seem to be working with no issues
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@angular/[email protected]
@ngtools/[email protected]
[email protected]
@timosalm And what are those "precise dependency versions" I only updated "angular-cli" to latest and that broke all. Changes here
@tarlepp I've created a separate issue for this issue introduced by angular-cli version 1.0.0-beta.22 : #3426
same problem:
angular 2.2.4
"@ngtools/webpack": "1.1.9", "typescript": "^2.0.10", "webpack": "^2.1.0-beta.27"
Please check https://github.com/angular/angular-cli/issues/3426#issuecomment-265277988 for a solution.
I've just today started to work with ngc and am hitting this same error.
I also stripped back my entryModule to the bare minimum.
import { NgModule, Component } from '@angular/core';
@Component({
selector: 'app',
template: '<h1>hello world</h1>',
styles: []
})
class AppComponent {}
@NgModule({
declarations: [AppComponent],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
All my @angular/ packages are aligned at version 2.2.4 and I've done my best to update all related webpack and typescript related plugins. There are other packages which may be out of date, but as none of them are imported via my AppModule, I can't see why'd they'd effect the compilers ability to load the AppModule (or at least report a meaningful error).
I've tried both relative and absolute paths for the entryModule.
@vascofernandes Instead of "^2.0.10" for typescript, try "2.0.10" exactly. I had it install 2.1.1 for me when I had ^ before.
Hi, I just tried that and and no success, same error.
shit, same here with cli "1.0.0-beta.22-1" :(