升级Windows7上VSCode后调试脚本报错:bad option: --inspect-brk=13927
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:
First, update your babel packages (adjust the command if you're using the newer
@babelscoped packages):npm install --save-dev babel-cli@latest babel-core@latest # Or for @babel users: npm install --save-dev @babel/cli@latest @babel/core@latestThen update your
launch.jsonto 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

