@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.
Yeah, in the end these are peer dependencies. If you update one you gotta update all...
@princemaple What do you mean? Yesterday I founded an example here https://github.com/blacksonic/angular2-aot-webpack (big thanks to the author). But my roadmap is a little bit different And now, I'm using webpack. Here is a part of my webpack.config. ..... { test: /.ts$/, loaders: env.aot ? ['awesome-typescript-loader?tsconfig=./client-code/src/tsconfig.json', 'angular2-template-loader', 'angular2-router-loader?genDir=./client-code/src/aot-compiled/app&aot=true'] : ['awesome-typescript-loader?tsconfig=./client-code/src/tsconfig.json', 'angular2-template-loader', 'angular2-router-loader'] } ...
With 'angular2-router-loader' I can split my bundles. Here are my "scripts" from packages.json
"scripts": { "prepublish": "yarn run build", "build": "yarn run clean && yarn webpack", "build:jit": "yarn run clean && yarn webpack -- --env.production", "build:production": "yarn run clean && yarn run compiler:aot && yarn webpack -- --env.aot --env.production", "compiler:aot": "ngc -p client-code/src/tsconfig-aot.json", "clean": "rimraf client-code/dist/* client-code/src/aot-compiled" },
Yeap, this is now working with Typescript 2.1.4!
angular-cli: 1.0.0-beta.24
node: 4.4.7
os: win32 x64
@angular/common: 2.4.2
@angular/compiler: 2.4.2
@angular/core: 2.4.2
@angular/forms: 2.4.2
@angular/http: 2.4.2
@angular/platform-browser: 2.4.2
@angular/platform-browser-dynamic: 2.4.2
@angular/router: 3.4.2
@angular/compiler-cli: 2.4.2
@ichent thanks for the information about the alternative!
@princemaple You are welcome!
I can also confirm that this is now working on the latest release versions.....
Angular 2.4.2 Router on 3.4.2 Typescript 2.1.4
Look for unwanted node_modules folders...
I experienced the problem with "AppModule is not an NgModule" after trying to run "./node_modules/.bin/ngc" to build a translated version (the build failed and the app wasn't translated). I tried to reinstall, change versions etc. but nothing worked. I finally realized that something had created an extra node_modules folder under the src folder. It only contains "@angular" and "rxjs" folders. When I delete this extra node_modules I can build again. However I still can't figure out how to use i18n - but that is another problem.
I had one time forgot to add "typings"="index.d.ts" key to my package.json file. Once I did, I stopped getting Please add @NgModule error
In case anyone stumbles across this, in my case it was misconfiguration. I was getting a null is not an NgModule error, which was because my entryModule missed of the name of the module:
new ngtools.AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: root('src/app/pager')
})
became
new ngtools.AotPlugin({
tsConfigPath: './tsconfig.json',
entryModule: root('src/app/pager') + '#PagerComponentModule'
})
ng build and ng serve is not working for me .gives error
ERROR in /home/pratiksha/migration//app/shared/user.service.spec.ts (7,3): Cannot find name 'beforeEach'.
ERROR in /home/pratiksha/migration/app/shared/user.service.spec.ts (13,3): Cannot find name 'it'.
ERROR in /home/pratiksha/migration/app/shared/user.service.spec.ts (14,5): Cannot find name 'expect'.
ERROR in PopoverModule is not an NgModule
ERROR in multi ./src/styles.css ./src/css/main.css ./src/css/font-awesome.min.css ./src/css/daterangepicker.css ./src/css/style.css ./src/css/style-bootstrap.css ./src/css/style-default.css ./src/css/style-material.css Module not found: Error: Can't resolve '/home/pratiksha/migration/src/css/main.css' in '/home/pratiksha/migration/node_modules/@angular/cli/models/webpack-configs' @ multi ./src/styles.css ./src/css/main.css ./src/css/font-awesome.min.css ./src/css/daterangepicker.css ./src/css/style.css ./src/css/style-bootstrap.css ./src/css/style-default.css ./src/css/style-material.css
try all but not working for me . angular cli is not working after upgrade -this is not supporting to .spec.ts file . why this is happing ?
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.