ts-node Debugger 配置 - Idea & VSCode

Me, ConfigurationDebugger
Back

Q: 如何实现 node 直接执行 ts 文件?

A: 通过执行这条命令

node -r ts-node/register FILE.js
node --inspect-brk -r ts-node/register FILE.js

Idea ts-node debugger 配置

<component name="RunManager">
...
<configuration name="ts-node" type="NodeJSConfigurationType" node-parameters="-r ts-node/register " path-to-js-file="$FilePathRelativeToProjectRoot$" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>
</component>
<configuration name="ts-node-inspect" type="NodeJSConfigurationType" node-parameters="--inspect-brk -r ts-node/register " path-to-js-file="$FilePathRelativeToProjectRoot$" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>

VSCode ts-node debugger 配置

{
"configurations": [
{
"name": "ts:debug",
"type": "node",
"request": "launch",
"args": [
"-r",
"ts-node/register",
"${relativeFile}"
]
}
]
}
{
"name": "ts:debug-inspect",
"type": "node",
"request": "launch",
"args": [
"--inspect-brk",
"-r",
"ts-node/register",
"${relativeFile}"
]
}
© Apolo Du.