我尝试调试在ts中编写的节点应用程序。我当然想使用ts源映射进行调试,但是不知何故,它在--inspect
(连接超时)和没有(没有源映射但可以连接)的情况下不起作用。
我的npm命令:
"dev": "nodemon -r source-map-support/register --watch ./src -e ts --exec \"npm run start\"",
"dev-inspect": "nodemon --inspect -r source-map-support/register ./src/index.ts --watch ./src -e ts --exec \"npm run start\"",
我的ts设置:
{
"compilerOptions": {
"types": [
"node"
],
"declaration": true,
"target": "es2016",
"module": "commonjs",
"outDir": "./build",
"rootDir": "./src",
"sourceMap": true,
"incremental": true,
"tsBuildInfoFile": "./build/.tsbuildinfo"
},
"include": [
"./src/**/*"
]
}
我的vs代码附加配置:
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"protocol": "inspector", // removed when tried without --inspect
},
在这里我该怎么办?
答案 0 :(得分:0)
您必须在“调试配置”中设置“节点”参数。
像这样:--需要ts-node / register 在Java脚本文件中,您必须设置server.ts或index.ts