39

The Ultimate VS Code Debug setup for Node.js

 4 years ago
source link: https://www.tuicool.com/articles/hit/VNrE3qY
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Recently I made a tweet about VSCode debug setup and many people asked how to do it.

muuQFje.jpg!web

The most important aspect that when we save the files, whole application re-start and debugger re-attach itself automatically. this is Super cool and super productive.

Ok, this is what you need to do it.

Step 1 — Create a VS Code setting file. “.vscode/settings.json”

This setting will turn on “Auto Attach”. You don’t need to create any launch.json. Auto Attach will do it automatically.

fyuY3ir.png!webi2QNBbA.png!web

Step 2— Edit package.json and add the following line.

zINf6ff.jpg!web

Nodemon will restart the server whenever there is a file change. When started with the “--inspect” switch, a Node.js process listens for a debugging client.

I wanted to use ES6 import statement, so Added ESM too. Visit https://github.com/standard-things/esm for more details.

with all these combinations, Its a super cool setup :sunglasses:

Yup, you need to do npm install too

zINf6ff.jpg!web

Thanks.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK