How to use nodemon with VSCode debugger?

Table Of Contents

Intro
Step by step
Demo

Intro

As a developer, you know that debugging is a crucial aspect of your workflow. It helps you identify and fix issues in your code, and ultimately improve your application’s perform…


This content originally appeared on DEV Community and was authored by Anderson Bosa

Table Of Contents

  • Intro
  • Step by step
  • Demo

Intro

As a developer, you know that debugging is a crucial aspect of your workflow. It helps you identify and fix issues in your code, and ultimately improve your application's performance. However, the process of debugging can be time-consuming and tedious, especially if you have to manually restart your application every time you make a change. This is where Nodemon and Visual Studio Code Debugger come in handy.

Nodemon is a tool that helps you automate the process of restarting your Node.js application whenever you make changes to your code. It monitors your application for changes and automatically restarts it when it detects any modifications. This saves you a lot of time and effort, as you don't have to manually stop and start your application every time you make changes.

Visual Studio Code Debugger, on the other hand, is an integrated development environment (IDE) that provides a powerful debugging experience for Node.js applications. It allows you to set breakpoints, step through your code, and inspect variables and objects at runtime.

VSCode provides a configuration for nodemon (see image below), but I couldn't use it at first, so I had to update to the package path installed in "node_modules".

This is because the "nodemon" package is installed in the project, not globally.

So how do I do it?

The steps to integrate nodemon in VSCode debugger are:

  1. Install nodemon as development dependency in your repository:
npm install -D nodemon
# or
npm install --save-dev nodemon
  1. Configure the VSCode "launch.json" as follows, updating the value of runtimeExecutable:
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "nodemon",
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen",
      "program": "${workspaceFolder}/app.js",
      "request": "launch",
      "restart": true,
      // "runtimeExecutable": "nodemon", /* ORIGINAL VALUE */
      "runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
      "type": "node"
    }
  ]
}

And it done!

For your convenience I created this demo repository: andersonbosa/nodemon-vscode-tutorial

Project banner

AboutTechnologiesContributionAuthorLicenseStatistics


💬 About

This repository shows how to integrate the nodemon tool with the VSCode Debugger. For more details, see the post.

🛠️ Technologies

🚀 Distribution

🤝 Contribution

All kinds of contributions are very welcome and appreciated!

👨‍💻 Author

📝 License

This project is under the MIT license.

📊 Statistics

Stargazers

Stargazers

Forkers

Forkers

Do you know how to integrate other languages with the VSCode Debugger? Please share in the comments! All kinds of contributions are very welcome and appreciated.


This content originally appeared on DEV Community and was authored by Anderson Bosa


Print Share Comment Cite Upload Translate Updates
APA

Anderson Bosa | Sciencx (2023-03-03T23:33:11+00:00) How to use nodemon with VSCode debugger?. Retrieved from https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/

MLA
" » How to use nodemon with VSCode debugger?." Anderson Bosa | Sciencx - Friday March 3, 2023, https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/
HARVARD
Anderson Bosa | Sciencx Friday March 3, 2023 » How to use nodemon with VSCode debugger?., viewed ,<https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/>
VANCOUVER
Anderson Bosa | Sciencx - » How to use nodemon with VSCode debugger?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/
CHICAGO
" » How to use nodemon with VSCode debugger?." Anderson Bosa | Sciencx - Accessed . https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/
IEEE
" » How to use nodemon with VSCode debugger?." Anderson Bosa | Sciencx [Online]. Available: https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/. [Accessed: ]
rf:citation
» How to use nodemon with VSCode debugger? | Anderson Bosa | Sciencx | https://www.scien.cx/2023/03/03/how-to-use-nodemon-with-vscode-debugger/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.