universal: Error: No NgModule metadata found for '[object Object]'
Bug 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?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 26 (2 by maintainers)
i have the same error any update ?
any updates?
Something like:
ng update @nguniversal/express-engine --migrate-only --from 8 --to 9