nestjs / ng-universal

Angular Universal module for Nest framework (node.js) 🌷
https://nestjs.com
MIT License
442 stars 68 forks source link

Prerender command fails due to UnhandledPromiseRejectionWarning #244

Closed jahnreektor closed 4 years ago

jahnreektor commented 4 years ago

I'm submitting a...


[ ] Regression 
[ x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When I run npm run prerender from a new Angular 9 app, I get the following error:

Prerendering 2 route(s) to /home/john/projects/nwoc/dist/nwoc/browser
(node:28450) UnhandledPromiseRejectionWarning: Error: renderModule method and/or AppServerModule were not exported from: /home/john/projects/nwoc/dist/nwoc/server/main.js.

I cross-compared this Nest-based version of universal to the @nguniversal/express-engine version, and the non-Nest version works and has the same main.server.ts contents.

Expected behavior

Prerender build should work.

Minimal reproduction of the problem with instructions

  1. Create an Angular 9 project from scratch.
  2. $ ng add @nestjs/ng-universal
  3. $ npm run prerender
kamilmysliwiec commented 4 years ago

Very interesting. So it seems that you have to move this line:

export * from './src/main.server';

From server/main.ts to the server.ts and everything will work fine (just tested). I'll update examples & schematics