[英]debugging typescript in vscode with autorestart
I am setting up a typescript project with node. 我正在使用节点设置一个打字稿项目。
I can debug my main.ts
file in vs code with this launch.json
configuration: 我可以使用
launch.json
配置在vs代码中调试main.ts
文件:
{
"type": "node",
"request": "launch",
"name": "Lancer le programme",
"program": "${workspaceRoot}/src/main.ts",
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
]
}
This works fine but there is no auto restart when I edit main.ts
这工作正常,但是在编辑
main.ts
时没有自动重启
To implement auto restart, I launch in my project directory tsc --watch
, and then this lauch configuration: 为了实现自动重启,我在项目目录
tsc --watch
,然后进行以下配置:
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--debug=5858"
],
"program": "${workspaceRoot}/src/main.ts",
"outFiles": [
"${workspaceRoot}/dist/**/*.js"
],
"restart": true,
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"sourceMaps": true
},
The above configuration does autorestart when I edit source files, but the vscode debugger doesn't break anymore... 当我编辑源文件时,上面的配置会自动重新启动,但是vscode调试器不会再中断...
Has anyone achieved : debugging typscript in vscode with autorestart ? 有没有人实现:使用自动重启功能在vscode中调试打字稿?
This is my launch.json
: 这是我的
launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "${workspaceFolder}/node_modules/nodemon/bin/nodemon.js",
"program": "${workspaceFolder}/build/index.js",
"restart": true,
"runtimeArgs": [
"--debug=5858",
"--inspect-brk"
],
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
Note that the prop program
must indicate compiled js file. 请注意,prop
program
必须指示已编译的js文件。 In your case it is ${workspaceRoot}/src/main.ts
, but should be ${workspaceRoot}/*compile directory eg. build*/main.js
在您的情况下,它是
${workspaceRoot}/src/main.ts
,但是应该是${workspaceRoot}/*compile directory eg. build*/main.js
${workspaceRoot}/*compile directory eg. build*/main.js
. ${workspaceRoot}/*compile directory eg. build*/main.js
Also make sure the typescript recompiles the files to the target directory. 还要确保打字稿将文件重新编译到目标目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.