How to use nodemon with VSCode debugger?

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 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

About
Technologies
Contribution
Author
License
Statistics

💬 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.

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
the-downsides-of-new-technology-come-fast-and-furious-(let’s-talk-about-ai)

The Downsides of New Technology Come Fast and Furious (Let’s talk about AI)

Next Post
10-cool-codepen-demos-(february-23)

10 Cool CodePen Demos (February 23)

Related Posts