angular-builders
angular-builders copied to clipboard
Unable to use aot while building or serviing
i have used angular builder and followed the steps but when i run ng serve i get the following error in browser
compiler.js:11902 Uncaught Error: No NgModule metadata found for 'AppModule'. at NgModuleResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.NgModuleResolver.resolve (compiler.js:11902) at CompileMetadataResolver.push../node_modules/@angular/compiler/fesm5/compiler.js.CompileMetadataResolver.getNgModuleMetadata (compiler.js:10544) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._loadModules (compiler.js:23876) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler._compileModuleAndComponents (compiler.js:23857) at JitCompiler.push../node_modules/@angular/compiler/fesm5/compiler.js.JitCompiler.compileModuleAsync (compiler.js:23817) at CompilerImpl.push../node_modules/@angular/platform-browser-dynamic/fesm5/platform-browser-dynamic.js.CompilerImpl.compileModuleAsync (platform-browser-dynamic.js:143) at PlatformRef.push../node_modules/@angular/core/fesm5/core.js.PlatformRef.bootstrapModule (core.js:4344) at Object../src/main.ts (main.ts:10) at webpack_require (bootstrap:76) at Object.0 (main.ts:16)
here is my configuration in angular.json
"build": { "builder": "@angular-builders/custom-webpack:browser", "options": { "outputPath": "dist", "index": "src/index.html", "main": "src/main.ts", "tsConfig": "src/tsconfig.app.json", "polyfills": "src/polyfills.ts", "assets": [ "src/assets", "src/favicon.ico", "src/src/manifest.json", "src/manifest.json" ], "styles": [ "src/styles.css", "src/assets/scss/main.scss", "node_modules/bootstrap/dist/css/bootstrap.min.css", "node_modules/ion-rangeslider/css/ion.rangeSlider.css", "node_modules/ion-rangeslider/css/ion.rangeSlider.skinHTML5.css", "node_modules/sweetalert2/dist/sweetalert2.css" ], "scripts": [ "node_modules/jquery/dist/jquery.min.js", "node_modules/tether/dist/js/tether.js", "node_modules/ion-rangeslider/js/ion.rangeSlider.min.js", "node_modules/moment/moment.js", "node_modules/sweetalert2/dist/sweetalert2.js" ], "customWebpackConfig": { "path": "./webpack.config.js", "mergeStrategies": { "module.rules": "prepend", "plugins": "prepend" }, } }, "configurations": { "production": { "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": true, "aot": true, "extractLicenses": true, "vendorChunk": true, "buildOptimizer": true, "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "serviceWorker": true } } }, "serve": { "builder": "@angular-builders/dev-server:generic", "options": { "browserTarget": "grocermax-web:build", "host": "beta.starquik.com", "port": 4200 }, "configurations": { "production": { "browserTarget": "grocermax-web:build:production" } } }
Have tried to look up this error in Google? Doesn't sound like a builder issue to me.
If you're convinced that it is, please create a minimal reproduction repository and I'll take a look. Thanks.
When i disable the builders and am back to stock angular json is works fine , will create a minimal repo for reproduction Thanks
I had the same problem. In my case, the problem was that the AppModule was nested in the same file with the call of the platformBrowserDynamic().bootstrapModule(AppModule)
@sakshamverenkar this is not related to the webpack builder as it doesn't override your metadata or smth else. Provided reproduction would be great except of text...
Closing since been stale.