DEV Community

Drakos
Drakos

Posted on • Edited on

1 1

Debug Node.js Typescript app using VS Code (Mac,Linux)

Using the following configuration I managed to debug flawlessly Node.js applications written in Typescript using the Visual Studio Code IDE. I have tested it on Mac OS and almost every Linux distro like Debian, Ubuntu, Arch.

Configure tsconfig.json

First of all, enable source maps "sourceMap": true and declarations "declarationMap": true, "declaration": true.

Don't forget to specify the destination folder using the outDir parameter.

Configure VSCODE

Paste the following snippet and change __MYAPP__ to the typescript file you want to debug and __MYDIST_FOLDER__ to the dist folder of your project.

Don't forget to whitelist (OUTPUT) port 9229 locally on your iptables.

Examples:
__MYAPP__ = src/app.ts
__MYDIST_FOLDER__ = dist

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug Node.js",
            "program": "${workspaceFolder}/__MYAPP__.ts",
            "outFiles": [
                "${workspaceFolder}/__MYDIST_FOLDER__/**/*.js"
            ],
            "sourceMaps": true,
            "port": 9229,
            "runtimeArgs": [
                "--inspect-brk=9229"
            ],
            "console": "integratedTerminal"
        }
    ]
}
Enter fullscreen mode Exit fullscreen mode

Support

If you liked this quick guide follow me on Twitter :) https://twitter.com/devcrafter91

Quadratic AI

Quadratic AI – The Spreadsheet with AI, Code, and Connections

  • AI-Powered Insights: Ask questions in plain English and get instant visualizations
  • Multi-Language Support: Seamlessly switch between Python, SQL, and JavaScript in one workspace
  • Zero Setup Required: Connect to databases or drag-and-drop files straight from your browser
  • Live Collaboration: Work together in real-time, no matter where your team is located
  • Beyond Formulas: Tackle complex analysis that traditional spreadsheets can't handle

Get started for free.

Watch The Demo 📊✨

Top comments (0)

Jetbrains Survey

Take part in the Developer Ecosystem Survey!

Share your thoughts and get the chance to win a MacBook Pro, an iPhone 16 Pro, or other exciting prizes. Help shape the coding landscape and earn rewards for your contributions!

Take the survey

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️