Error: No NgModule metadata found for '[object Object]'
See original GitHub issueBug Report
What is the expected behavior?
Load the webpage using SSR.
What is the current behavior?
An error pops up when trying to to open up the browser:
Error: No NgModule metadata found for '[object Object]'.
at NgModuleResolver.resolve (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:11967:27)
at CompileMetadataResolver.getNgModuleMetadata (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:10609:47)
at JitCompiler._loadModules (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23932:55)
at JitCompiler._compileModuleAndComponents (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23913:40)
at JitCompiler.compileModuleAsync (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23873:41)
at CompilerImpl.compileModuleAsync (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js:195:35)
at /Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:109:25
at new ZoneAwarePromise (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/zone.js/dist/zone-node.js:891:29)
at getFactory (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:95:12)
at View.engine (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:74:13)
at View.render (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/express/lib/response.js:1008:7)
at app.get (/Users/shynet/Documents/Git/nodejs-angular-starter/out/src/ng-app.js:31:17)
at Layer.handle [as handle_request] (/Users/shynet/Documents/Git/nodejs-angular-starter/node_modules/express/lib/router/layer.js:95:5)
What modules are related to this issue?
- [ ] aspnetcore-engine
- [ ] common
- [X] express-engine
- [ ] hapi-engine
- [ ] module-map-ngfactory-loader
Minimal reproduction with instructions:
I’m running my own custom server and build which includes the following changes to angular.json:
"server": {
"builder": "@angular-devkit/build-angular:server",
"options": {
"outputPath": "dist/server",
"main": "src/main.server.ts",
"tsConfig": "src/tsconfig.server.json",
"bundleDependencies": "all"
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}]
}
}
}
I set “bundleDependencies” to “all” in order for the server side to include the node_modules.
I’m not using the webpack as mentioned in the tutorial because my own server uses some NPM modules like bcrypt which cannot be compiled using webpack.
This is my code: https://github.com/shy2net/nodejs-angular-starter/tree/feature/angular-universal
You can simply clone it, and run the following to start it:
npm install
npm run build
npm start
What is the use-case or motivation for changing an existing behavior?
My own server cannot use webpack as mentioned in the tutorial and I cannot make it work as it should.
Environment:
@nguniversal versions
- aspnetcore-engine:
- common:
- express-engine:
- hapi-engine:
- module-map-ngfactory-loader:
<!--
Angular CLI: 6.0.8
Node: 8.11.3
OS: darwin x64
Angular: 6.1.7
... animations, common, compiler, core, forms, http
... platform-browser, platform-browser-dynamic, platform-server
... router
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.8 (cli-only)
@angular-devkit/core 0.6.8 (cli-only)
@angular-devkit/schematics 0.6.8 (cli-only)
@schematics/angular 0.6.8 (cli-only)
@schematics/update 0.6.8 (cli-only)
rxjs 6.3.2
typescript 2.9.2
-->
Is there anything else we should know?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:26 (2 by maintainers)
Top Results From Across the Web
Error: No NgModule metadata found for '[object Object]'
You need to remove "bundleDependencies": "all" from angular.json file (under server -> options). Not sure why it's breaking, ...
Read more >Angular – All Possible Solutions for 'No NgModule' - Stack 24/7
The error “No NgModule metadata found for 'AppModule'” could be caused by various reason: Moving Angular project folder. Upgrading dependencies.
Read more >ERROR in No NgModule metadata found for 'AppModule ...
I am getting [ng] ERROR while ionic serve in No NgModule metadata found for 'AppModule' this error. I searched a lot but not...
Read more >no ngmodule metadata found for 'appservermodule', error no ...
ERROR in No NgModule metadata found for 'AppModule'. The error could possibly be becuase of following reasons: There is a statement of the...
Read more >Getting "No NgModule metadata found for 'class{}'." with ...
Uncaught Error: No NgModule metadata found for 'class{}'. ... I have tried to debug the issue and it seems that my AppModule is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
i have the same error any update ?
any updates?