为什么vscode控制台显示调试失败,即使没有失败?

时间:2019-11-01 13:07:49

标签: node.js typescript visual-studio-code console

从我的工作区配置中:

{
    "launch": {
        "configurations": [
            {
                "name"             : "Debug Current",
                "type"             : "node",
                "request"          : "launch",
                "cwd"              : "${fileDirname}",
                "runtimeExecutable": "npm",
                "runtimeArgs"      : ["run-script", "debug"],
                "port"             : 9229,
                "sourceMaps"       : true,
                "console"          : "integratedTerminal",
            },
        ],
        "compounds": []
    }
}

触发package.json中的脚本:

"scripts": {
   "debug": "node -r ts-node/register --inspect-brk=9229 src/index.ts"
}

index.ts很简单:

console.log('test')

// process.exit(0) // does nothing

控制台输出:

Debugger attached.
test
Waiting for the debugger to disconnect...
Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! __PACKAGE.NAME@0.0.0 debug: `node -r ts-node/register --inspect-brk=9229 src/index.ts`
npm ERR! Exit status 137
npm ERR! 
npm ERR! Failed at the __PACKAGE.NAME@0.0.0 debug script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

尽管普通控制台没有此问题。但是我需要这个控制台来处理用户输入。

根据我的测试,只有在调试器连接时,才会发生这种情况。

node -r ts-node/register src/index.ts # exit code === 0

知道为什么调试器会导致这种情况吗?

0 个答案:

没有答案