vscode 无法启动节点应用
vscode can't launch node app
我正在尝试使用 Visual Studio 代码和 gulp.
设置基于打字稿的快速应用程序工作流程
这是我的项目结构:
src/ <-- souce files
Start.ts
Server.ts
models/
Contact.ts
Organization.ts
bin/ <-- compiled output
Start.js
Start.js.map
...
tsconfig.json
gulpfile.json
package.json
.vscode/
launch.json
执行以下命令序列,我可以在集成终端中编译和启动我的应用程序:
> tsc
> node --debug-brk ./bin/Start.js
此时,我可以使用默认的 "attach to process" 命令成功附加到我的应用程序(它甚至可以正确命中打字稿文件中的断点,耶!):
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
但是,使用F5
启动每次都失败。调试控制台上没有输出,几秒钟后我在顶部看到一条错误横幅,上面写着 Cannot connect to runtime via 'legacy' protocol; consider using 'inspector' protocol (timeout after 10000 ms).
这是我的启动配置(在 launch.json 中):
{
"type": "node",
"request": "launch",
"name": "Launch Program",
// Using compiled .js file. vscode should use the sourcemap to correlate
// with breakpoints in the source file
"program": "${workspaceRoot}/bin/Start.js",
"outFiles": [ "${workspaceRoot}/bin/**/*.js" ]
}
我尝试打开调试控制台。每次保存 launch.json 文件时,都会出现以下错误:Cannot read property '_runner' of undefined: TypeError: Cannot read property '_runner' of undefined
in shell.ts:426
谷歌搜索错误,我遇到了 this bug
这个错误是什么意思?有什么解决方法吗?我该怎么办???
我无法告诉您错误的含义,但下面我将给出一个启动配置示例,该示例适用于与您类似的环境:
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch Server",
// Type of configuration.
"type": "node2",
// Workspace relative or absolute path to the program.
"program": "${workspaceRoot}/server/app.ts",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": "${workspaceRoot}",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": ["--nolazy"],
// Environment variables passed to the program.
"env": {
"NODE_ENV": "development"
},
// Use JavaScript source maps (if they exist).
"sourceMaps": true,
"request": "launch",
"outFiles": [
"${workspaceRoot}/dist/dev/*/*.js"
]
}
注意 type
中设置为 node2
和 program
指向 ts 而不是 js 的区别。
希望对您有所帮助。
小事往往会造成最大的问题。
问题是我选择了 "Attach to Process" 任务(在调试模式下拉列表中)而不是 "Launch Program" 任务。因此,当我按下 F5
时,vscode 试图附加到一个已经 运行 的进程,而不是启动一个新进程。
**捂脸**
我正在尝试使用 Visual Studio 代码和 gulp.
设置基于打字稿的快速应用程序工作流程这是我的项目结构:
src/ <-- souce files
Start.ts
Server.ts
models/
Contact.ts
Organization.ts
bin/ <-- compiled output
Start.js
Start.js.map
...
tsconfig.json
gulpfile.json
package.json
.vscode/
launch.json
执行以下命令序列,我可以在集成终端中编译和启动我的应用程序:
> tsc
> node --debug-brk ./bin/Start.js
此时,我可以使用默认的 "attach to process" 命令成功附加到我的应用程序(它甚至可以正确命中打字稿文件中的断点,耶!):
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"address": "localhost",
"port": 5858
}
但是,使用F5
启动每次都失败。调试控制台上没有输出,几秒钟后我在顶部看到一条错误横幅,上面写着 Cannot connect to runtime via 'legacy' protocol; consider using 'inspector' protocol (timeout after 10000 ms).
这是我的启动配置(在 launch.json 中):
{
"type": "node",
"request": "launch",
"name": "Launch Program",
// Using compiled .js file. vscode should use the sourcemap to correlate
// with breakpoints in the source file
"program": "${workspaceRoot}/bin/Start.js",
"outFiles": [ "${workspaceRoot}/bin/**/*.js" ]
}
我尝试打开调试控制台。每次保存 launch.json 文件时,都会出现以下错误:Cannot read property '_runner' of undefined: TypeError: Cannot read property '_runner' of undefined
in shell.ts:426
谷歌搜索错误,我遇到了 this bug
这个错误是什么意思?有什么解决方法吗?我该怎么办???
我无法告诉您错误的含义,但下面我将给出一个启动配置示例,该示例适用于与您类似的环境:
{
// Name of configuration; appears in the launch configuration drop down menu.
"name": "Launch Server",
// Type of configuration.
"type": "node2",
// Workspace relative or absolute path to the program.
"program": "${workspaceRoot}/server/app.ts",
// Automatically stop program after launch.
"stopOnEntry": false,
// Command line arguments passed to the program.
"args": [],
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
"cwd": "${workspaceRoot}",
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
"runtimeExecutable": null,
// Optional arguments passed to the runtime executable.
"runtimeArgs": ["--nolazy"],
// Environment variables passed to the program.
"env": {
"NODE_ENV": "development"
},
// Use JavaScript source maps (if they exist).
"sourceMaps": true,
"request": "launch",
"outFiles": [
"${workspaceRoot}/dist/dev/*/*.js"
]
}
注意 type
中设置为 node2
和 program
指向 ts 而不是 js 的区别。
希望对您有所帮助。
小事往往会造成最大的问题。
问题是我选择了 "Attach to Process" 任务(在调试模式下拉列表中)而不是 "Launch Program" 任务。因此,当我按下 F5
时,vscode 试图附加到一个已经 运行 的进程,而不是启动一个新进程。
**捂脸**