Skip to content

Instantly share code, notes, and snippets.

@rahulballal
Forked from joseluisq/Debugging.md
Created June 22, 2022 04:56
Show Gist options
  • Save rahulballal/eb3b7f9160c9316c97270dc8bc3e413d to your computer and use it in GitHub Desktop.
Save rahulballal/eb3b7f9160c9316c97270dc8bc3e413d to your computer and use it in GitHub Desktop.
A simple NodeJS App debugging example in VS Code using Nodemon.

NodeJS debugging in VS Code with Nodemon

A simple NodeJS App debugging example in VS Code using Nodemon.

Note: Feel free to customize .vscode/launch.json and ./nodemon.json files.

Install

yarn add nodemon --dev

Debugging

Add debug to your package.json script section:

+ "debug": "nodemon --debug server.js",

Run Nodemon:

yarn debug

Finally, select the attach configuration before in your VS Code and go to Debug > Start debugging F5

⚡️ Enjoy!

{
"version": "1.0.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch",
"cwd": "${workspaceFolder}",
"runtimeExecutable": null,
"args": [],
"stopOnEntry": false,
"runtimeArgs": [ "--nolazy" ],
"preLaunchTask": null,
"env": {
"NODE_ENV": "development",
"LOG_LEVEL": "debug"
},
"console": "internalConsole",
"program": "${workspaceFolder}/server.js",
"outFiles": []
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 5858,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outFiles": [],
"localRoot": "${workspaceFolder}",
"remoteRoot": null
}
]
}
{
"env": {
"TZ": "UTC",
"NODE_ENV": "development",
"LOG_LEVEL": "debug"
},
"watch": [ "./src" ],
"ext": "js",
"signal": "SIGTERM"
}
{
"env": {
"TZ": "UTC",
"NODE_ENV": "development",
"LOG_LEVEL": "debug"
},
"watch": [
"src"
],
"ext": "ts",
"ignore": [
"src/**/*.spec.ts"
],
"signal": "SIGTERM",
"exec": "npm run lint && ts-node -r tsconfig-paths/register src/main.ts"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment