Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug Angular universal?

I am using Angular Universal Starter repo. In angular 4 universal for ssr we could debug browser and node part of application in dev mode(see console), but now I do not see way to debug node part. I tried to execute ts-node server.ts with some changes( paths to files, etc), but angular seems needs aot compiled app and

throw Error: You must pass in a NgModule or NgModuleFactory to be bootstrapped.

from docs:

Development (Client-side only rendering) - run npm run start which will start ng serve

Production (also for testing SSR/Pre-rendering locally) - npm run build:ssr && npm run serve:ssr

At first glance debug on Node.js in development do not work. At least from the box. May be someone resolve this issue.

like image 744
dimson d Avatar asked Mar 02 '18 22:03

dimson d


People also ask

What is universal in Angular?

Angular Universal executes on the server, generating static application pages that later get bootstrapped on the client. This means that the application generally renders more quickly, giving users a chance to view the application layout before it becomes fully interactive.


1 Answers

I think this small piece of code can help you

create the project

ng n debuggable-universal-server --interactive=false  cd debuggable-universal-server 

add universal

ng add @nguniversal/express-engine --clientProject debuggable-universal-server 
like image 117
Muhammad Numan Avatar answered Sep 28 '22 21:09

Muhammad Numan