【发布时间】:2017-08-01 01:30:36
【问题描述】:
我正在尝试设置调试配置,以便使用 Mocha 在 Node 应用程序中运行测试。 我有 Ubuntu 作为 Linux 的 Windows 子系统运行,我的 Visual Studio Code 设置为使用 Bash 作为集成终端。
这是我的launch.json 配置:
{
"name": "Launch via NPM",
"type": "node",
"request": "launch",
"console": "integratedTerminal",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"test"
],
"protocol": "inspector",
"port": 5858
...
}
这将在集成终端中运行我的测试,但在尝试附加到调试器时总是会超时,并出现以下错误:
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:5858).
这也是它在开始运行测试之前在终端中显示的内容:
cd c:\Users\abc\MyProject ; npm test
-bash: cd: c:UsersabcMyProject : No such file or directory
知道如何确保它连接调试器吗?
【问题讨论】:
-
换个端口有用吗?尝试设置
diagnosticLogging: true并查看日志。 -
尝试了不同的端口。也不允许使用
diagnosticLogging属性
标签: node.js visual-studio-code windows-subsystem-for-linux