You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

升级Windows7上VSCode后调试脚本报错:bad option: --inspect-brk=13927

Solution for "bad option: --inspect-brk=13927" Error in VS Code Debugging with babel-node

Hey, let's break down what's happening here and fix that debugging error you're seeing after upgrading VS Code on Windows 7.

The Root Cause

VS Code's Node.js debugger was updated to use the newer --inspect-brk debugging protocol (standard for Node.js 8+), but your launch.json is still configured with the old --debug-brk flag. When VS Code tries to start the debugger, it automatically injects the --inspect-brk parameter alongside your --debug-brk setting—and your version of babel-node doesn't support having both flags, or doesn't support the new --inspect-brk flag at all.

Fix Options

Option 1: Force VS Code to Use the Legacy Debug Protocol

If you want to keep your current babel-node version, add the protocol field to your launch.json to tell VS Code to stick with the old debugging protocol that works with --debug-brk:

{
  "type": "node",
  "request": "launch",
  "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
  "runtimeArgs": ["--debug-brk=13927"], // Match the port from your error message
  "protocol": "legacy", // This line prevents VS Code from injecting --inspect-brk
  "internalConsoleOptions": "openOnSessionStart",
  "name": "Launch Task",
  "program": "${workspaceFolder}/src/tasks/checkArrival.js",
  "cwd": "${workspaceRoot}"
}

Save the file, then try launching your debugger again—this should resolve the conflicting flag error.

Option 2: Upgrade babel-node to Support the New Debug Protocol

If you're open to updating your dependencies, newer versions of babel-cli (which includes babel-node) fully support the --inspect-brk flag. Here's how to do this:

  1. First, update your babel packages (adjust the command if you're using the newer @babel scoped packages):

    npm install --save-dev babel-cli@latest babel-core@latest
    # Or for @babel users: npm install --save-dev @babel/cli@latest @babel/core@latest
    
  2. Then update your launch.json to use the new flag instead of --debug-brk:

    {
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
      "runtimeArgs": ["--inspect-brk=13927"],
      "internalConsoleOptions": "openOnSessionStart",
      "name": "Launch Task",
      "program": "${workspaceFolder}/src/tasks/checkArrival.js",
      "cwd": "${workspaceRoot}"
    }
    

Quick Compatibility Check

  • If you go with the legacy protocol option, Node.js versions <8 will work most reliably
  • If upgrading babel-node, Node.js 8+ is recommended for full support of the new debugging protocol

内容的提问来源于stack exchange,提问作者David Faizulaev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:40:30