Last active
June 10, 2018 01:13
-
-
Save asalhani/ddc506a635a5de5eeddf84888cd870ac to your computer and use it in GitHub Desktop.
How to debug Node.JS script file (app).md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Methode #1: | |
To debug in chrome dev tool: <br/> | |
1. run ```node --inspect-brk app.js``` | |
2. go to ```chrome://inspect ``` | |
---------------------------------- | |
#### Methode #2: <br/> | |
Using VS Code debugging <br/> | |
1. Create new debug profile (Node : Lunch a program) | |
2. hit F5 | |
3. Update lunch.json file as following: | |
``` | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Launch Node.JS Program", | |
"program": "${file}", | |
"cwd": "${workspaceRoot}" | |
} | |
``` | |
---------------------------------- | |
#### Methode #3: Debug Node.js when running on nodemon <br/> | |
1. Add new debug profile to lunch.json (Node: Attach to process) profile: | |
``` | |
{ | |
"type": "node", | |
"request": "attach", | |
"name": "Attach to Process", | |
"port": 9229, | |
"restart": true | |
} | |
``` | |
2. Install nodemon ``` npm install -g nodemon ``` | |
3. Run app in nodemon: ``` nodemon --inspect-brk app.js ``` | |
4. Attach VS code to the process: F5 --> Choose "Attach to process" profile | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment