在尝试调试mts文件时,我很难获得要绑定的断点。代码运行并输出正确的结果(在本例中只是一堆console.log语句),有趣的是,如果我首先转到生成的mjs文件并在该文件中插入一个断点,那么它将在mts文件中获取断点。如果mjs文件中没有断点,则调试器不会附加。
设置:
17.3.1
{
"type": "node",
"request": "launch",
"name": "Launch Debug",
"program": "${workspaceFolder}/lib/src/debug.mjs",
"preLaunchTask": "tsc: build - tsconfig.debug.json"
} {
"compilerOptions": {
"target": "ES2020",
"lib": ["DOM", "DOM.Iterable", "ES2020"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"module": "ES2020",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"typeRoots": ["./types", "./node_modules/@types"]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", "**/*.mts"],
"exclude": ["node_modules", "types"]
} {
"extends": "./tsconfig.json",
"compilerOptions": {
"noEmit": false,
"sourceMap": true,
"outDir": "lib"
}
}是否有人能够在不将package.json类型设置设置为模块的情况下调试mts文件,或者我是否应该向类型记录小组提交一个问题?
发布于 2022-01-12 03:53:06
我想出来了!我需要在启动配置中添加"pauseForSourceMap":true,如下所示:
{
"type": "node",
"request": "launch",
"name": "Launch Debug",
"program": "${workspaceFolder}/lib/src/debug.mjs",
"preLaunchTask": "tsc: build - tsconfig.debug.json",
"pauseForSourceMap": true
}https://stackoverflow.com/questions/70661161
复制相似问题