angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

@ngtools/webpack complainning about not an NgModule

Open princemaple opened this issue 10 years ago • 71 comments

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.

princemaple avatar Nov 16 '16 11:11 princemaple

It works for me with @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]

avitiw avatar Dec 08 '16 10:12 avitiw

Yes, when I downgraded from Typescript 2.1.4 to 2.0.10 it works. I wish I could tell you why.

Regards,

Dwight

On Thu., 8 Dec. 2016 at 11:52 am, Avinash Tiwari [email protected] wrote:

It works for me with

@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]

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/3157#issuecomment-265711755, or mute the thread https://github.com/notifications/unsubscribe-auth/AAbtmkSTOg-mbj3a4grQ1EkxKMH2PdlBks5rF-FTgaJpZM4KzvfR .

dwightgunning avatar Dec 08 '16 10:12 dwightgunning

Fixed a lot of issues with path resolution and having your tsconfig in a different path than your webpack config. Closing this as fixed.

hansl avatar Dec 08 '16 22:12 hansl

@hansl I'm experiencing this with an cli-built application that I upgraded from 1.0.0-beta.21 to 1.0.0-beta.22-1.

10% building modules 2/2 modules 0 active(node:39556) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: AppModule is not an NgModule

As far as I know the webpack config should be transparent to cli users, unless I'm missing something.

arciisine avatar Dec 09 '16 13:12 arciisine

For me, fixing the versions in package.json fixed it:

  • Angular 2.2.3
  • Router on 3.2.3
  • Typescript 2.0.10

brugsel avatar Dec 12 '16 09:12 brugsel

I can confirm it breaks with TypeScript 2.1.4 and then works again after downgrading to 2.0.10.

@hansl please reopen this so someone can take a look, or at least point us to another issue where you're tracking this.

colltoaction avatar Dec 14 '16 03:12 colltoaction

Fixed a lot of issues with path resolution and having your tsconfig in a different path than your webpack config. Closing this as fixed.

@hansl is this fixed in master?

beeman avatar Dec 14 '16 04:12 beeman

As per @tinchou and @brugsel I am also unable to build unless I keep to the versions below

Angular 2.2.3 Router on 3.2.3 Typescript 2.0.10

ghost avatar Dec 15 '16 15:12 ghost

My external modules only builds when:

Angular: 2.2.3 Router: 3.2.3 Typescript: 2.0.10 Angular-Cli: 1.0.0-beta.15

I've tried several combinations.

npm uninstall angular-cli -g
npm cache clean
npm install [email protected] -g

rgiosa avatar Dec 22 '16 14:12 rgiosa

@hansl this is a legitimate issue and should be reopened, I also recently upgraded to Angular-Cli:1.0.0-beta.24 and encountered this breaking change, preventing work on a production site. Downgrading to beta.22 and related packages resolved the issue. It's possible that you mean this has been fixed post beta.24, if possible is there a workaround until the fix is released?

misterwise avatar Dec 25 '16 11:12 misterwise

It builds (dev and prod) even though the error is shown. I use latest versions:

  • angular 2.4.1
  • typescript 2.1.4
  • angular-cli 1.0.0-beta.24

anderflash avatar Dec 25 '16 16:12 anderflash

Hello. I have this error today, after I updated angular to 2.4.1. Today I saw many errors, and "AppModule is not an NgModule", and "cannot read property codegen" and so on. Then I changed my package.json to previous state (worked state), and now I'm getinng an error "AppModule is not an NgModule". A current package.json is { angular: 2.2.3, router: 3.2.3, "@ngtools/webpack": "1.1.9", "typescript": "2.0.10", "webpack": "2.1.0-beta.25" }

and this is not working. Changing from 2.2.3 to 2.2.4 not solve this problem.

ichent avatar Dec 26 '16 12:12 ichent

I had the "AppModule is not an NgModule" error plus various others. I've somehow now got Angular 2.4.1 working with Angular CLI 1.0.0-beta.24 and Typescript 2.0.10 !! :o)

(But not with 2.1.4, that produced the AppModule is not an NgModule". Given this I suspect I need to wait a while for Angular to work with Typescript 2.1.4.)

I followed the steps here for updating Angular-CLI

And here are my dependencies from package.json:

dependencies": { "@angular/common": "2.4.1", "@angular/compiler": "2.4.1", "@angular/core": "2.4.1", "@angular/forms": "2.4.1", "@angular/http": "2.4.1", "@angular/platform-browser": "2.4.1", "@angular/platform-browser-dynamic": "2.4.1", "@angular/platform-server": "2.4.1", "@angular/router": "3.4.1", "@angularclass/conventions-loader": "^1.0.2", "@angularclass/hmr": "~1.2.2", "@angularclass/hmr-loader": "~3.0.2", "core-js": "^2.4.1", "http-server": "^0.9.0", "ie-shim": "^0.1.0", "jasmine-core": "^2.5.2", "reflect-metadata": "^0.1.9", "rxjs": "~5.0.2", "zone.js": "~0.7.4",
"ts-helpers": "^1.1.1" }, "devDependencies": { "@angular/compiler-cli": "2.4.1", "@types/jasmine": "2.5.38", "@types/node": "^6.0.42", "angular-cli": "1.0.0-beta.24", "codelyzer": "~2.0.0-beta.1", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "2.5.0", "karma": "1.2.0", "karma-chrome-launcher": "^2.0.0", "karma-cli": "^1.0.1", "karma-jasmine": "^1.0.2", "karma-remap-istanbul": "^0.2.1", "protractor": "~4.0.13", "ts-node": "1.2.1", "tslint": "^4.0.2", "typescript": "2.0.10" }

greenginger avatar Jan 05 '17 12:01 greenginger

@hansl I guess you closed this issue just because you assumed it should be somehow fixed, without checking it and asking affected users, right? Please reopen it and please let's find solution for this issue - it's pretty critical thing. Angular CLI is not usable at this moment because of this issue.

e-oz avatar Jan 05 '17 18:01 e-oz

I need(ed?) TypeScript 2.1.x for Generator support. Typescript 2.2.3, 2.1.4, and 2.1.3-insiders.20161130 didn't work (I couldn't find 2.1.3). Dropping to 2.0.10 like suggested fix it.

I should note an older project had "angular-cli": "^1.0.0-beta.19-3", and "typescript": "v2.1.1" and that worked for both ng serve and ng test. Whatever, it works and only took 1 🍺.

JesterXL avatar Jan 06 '17 01:01 JesterXL

Hello. Today I removed @ngtools/webpack from my project and now I'm using webpack for AoT. I'm happy.

ichent avatar Jan 09 '17 13:01 ichent

How is that done?

On Tue., 10 Jan. 2017, 00:15 Ivan Kishkevich, [email protected] wrote:

Hello. Today I removed @ngtools/webpack from my project and now I'm using webpack for AoT. I'm happy.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/3157#issuecomment-271281411, or mute the thread https://github.com/notifications/unsubscribe-auth/ABRKNE4K2_0EGWHoo9fho4cB3LPyh1tGks5rQjLjgaJpZM4KzvfR .

princemaple avatar Jan 09 '17 13:01 princemaple

Angular 2.4.2 just landed which fixed TS 2.1 support. I've successfully built 2.4.2 with typescript 2.1.4 and beta 24 of the cli.

arciisine avatar Jan 09 '17 13:01 arciisine

@arciisine Which Angular dependency has to be updated to 2.4.2? common, core?

sbley avatar Jan 09 '17 14:01 sbley

@sbley compiler-cli at least, preferable all.

jkuri avatar Jan 09 '17 14:01 jkuri