Mark Ku's Blog

The Problem

More and more applications are built with Node.js, and they often throw confusing errors. So I put together a quick reference on how to debug Node.js, Vue CLI, and Webpack plugins.

1. Debugging Node.js

1. Add the --inspect flag to the JS file you want to run for remote debugging (default port is 9229)

node --inspect app.js 

2. Then in Chrome's address bar, type chrome://inspect, and you'll see the screen below.

Chrome inspect page showing DevTools devices and remote target
Chrome inspect page showing DevTools devices and remote target

3. Enter the default debugging port

Chrome DevTools port forwarding settings showing localhost:9229
Chrome DevTools port forwarding settings showing localhost:9229

4. Or click the debug button in DevTools

Chrome DevTools Network tab with highlighted debug button
Chrome DevTools Network tab with highlighted debug button

2. Debugging Vue CLI (main.js)

VSCode debugging Vue.js code, showing debug options and terminal
VSCode debugging Vue.js code, showing debug options and terminal

1. Add a debugger statement in main.js

Vue CLI main.js code in VSCode with a debugger statement
Vue CLI main.js code in VSCode with a debugger statement

2. Add the following script to package.json

"debug": "node ./node_modules/@vue/cli-service/bin/vue-cli-service.js serve"

3. Run npm run debug

4. In main.js, press F5

5. Enter the debug URL "localhost:8080"

VSCode debugging Vue.js code with debug panel and terminal
VSCode debugging Vue.js code with debug panel and terminal

At this point the breakpoint will hit in main.js

VSCode debugging main.js, breakpoint paused on line 17
VSCode debugging main.js, breakpoint paused on line 17

3. Debugging the Webpack Plugin in vue.config

1. Add a debugger statement in the chainWebpack method of vue.config

VSCode chainWebpack method showing debugger and path aliases
VSCode chainWebpack method showing debugger and path aliases

2. Add the following script to package.json

"debugbuild": "node --inspect-brk=9229 ./node_modules/@vue/cli-service/bin/vue-cli-service.js build" 

3. Type chrome://inspect into the browser address bar > enter the network target port

4. Back in VS Code > run npm run debug in the terminal

5. The breakpoint will now hit inside the chainWebpack function

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··602

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··490

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··333

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··264

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning

Training Your Own AI Voice: Hardware Requirements, Open-Source Model Comparison, and LoRA Fine-Tuning
Mark Ku
··221

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··215

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11