Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular universal 'npm run prerender' command never stops

I'm using Angular universal with Angular 9 and Angular Fire 6.

I managed to prerender my application with npm run prerender without any errors.
My routes get pre rendered and the index.html files looks fine.

Except the command itself, it never finishes.
The last lines i get:

...
Prerendering 4 route(s) to {{projekt URL}}\browser
CREATE {{projekt URL}}\browser\index.html (66857 bytes)
CREATE {{projekt URL}}\browser\home\index.html (66857 bytes)
CREATE {{projekt URL}}\browser\edit\index.html (66857 bytes)
CREATE {{projekt URL}}\browser\login\index.html (66857 bytes)
like image 914
Norbert Bartko Avatar asked Jun 19 '20 15:06

Norbert Bartko


1 Answers

I had the same problem and found out, that somehow the forked process(es) did not terminate correctly. I didn't know how to help but use a small workaround, which I'll execute as NPM script before the actual prerendering:

"prerender:fix-exit": "sed -i -e \"s/}))().then().catch();/}))().then(()=>process.exit(0)).catch(()=>process.exit(1));/g\" ./node_modules/@nguniversal/builders/src/prerender/render.js",

It will basically call process.exit(0) in case of success, or process.exit(1) in case of error. In theory, this should also work with a builder configuration of numProcesses > 1.

like image 53
papagei9 Avatar answered Sep 28 '22 00:09

papagei9