0

How can I debug the entire App NodeJS and ExpressJS? I tried using 'ng build --prod' , then copying files in dist to my views folder . I want that whenever I change codes , I refresh browser and its codes are also going to change. Thank you!

Cossintan
  • 114
  • 4
  • 12
  • You are going to have to provide significantly more information than that. What specifically are you trying to debug? What is not working as expected? – aug Jul 05 '17 at 04:52
  • Yes but all I want to know that how can I test and fix bugs, then I can see code change after I refresh . I googled it but can't figure out – Thien Anhhhhh Jul 05 '17 at 04:56

2 Answers2

0

Use --inspect to debug ExpressJS

  • Enable inspector agent
  • Listen on default port (9229)

Disable minify or uglify for Angualar JS, so that you can debug on Chrome

For your reference https://nodejs.org/en/docs/guides/debugging-getting-started/

For prod, by default it will get uglified

Ravikiran Reddy Kotapati
  • 1,942
  • 1
  • 19
  • 24
0

I assume you are using Angular2 (AngularJS 2 has no meaning)

If you want to debug only server(NodeJS + ExpressJS)
Use WebStorm. It is very easy with WebStorm to mark break points and then go to 'Run / Debug Configurations' and add new Node.js profile. Set the proper properties in the configuration area. Now you can run the server in debug mode by clicking small green color bug icon in top right corner in the IDE. When you send a request from the client the server will pause at the break point. WebStorm will give you lots of helpful features while debugging.

If you want to debug angular2 application
you can use Google Chrome Extension Augury to debug an Angular2 application. Augury documentation will help you how to use it.

Additionally I want you to tell you is,

  • while you are developing don't use ng build. use ng serve and serve the angular app in different port(default 4200) and node server in another port (default 3000). Then open the angular app in browser with disabling web-security (CORS disabled - here). This will give you more flexible development experience.

  • Use Nodemon for start nodeJS server. It will automatically restart the server with the changes of your source code.

Thank you.

Community
  • 1
  • 1
Viran Malaka
  • 407
  • 3
  • 9