我遵循本文档中的Next.js说明:https://nextjs.org/docs/advanced-features/debugging#using-the-debugger-in-visual-studio-code
尝试调试我的Next.js项目。进程启动,调试器正确连接,并显示调试的日志消息。然而,当我设置一个断点时,它仍然是褪色的,当我悬停它时,VSCode会显示“未绑定的断点”。更不用说,调试器不会在断点处停止。
但是,如果我使用关键字" debugger“,那么调试器会在我使用它的地方停止。
我的系统:
"next": "9.4.4",
tsconfig.json:
{
"compilerOptions": {
"downlevelIteration": true,
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"sourceMap": true,
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"allowUnreachableCode": false,
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"types/": [
"src/types/index"
],
"types/*": [
"src/types/*",
"src/types/index"
],
"data/*": [
"src/data/*"
],
},
},
"exclude": [
"node_modules"
],
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"next.config.js"
],
"compileOnSave": true
}
发布于 2020-11-14 00:40:22
我在TypeScript + React中遇到了断点未绑定的问题。这是我的launch.json,我添加了这些属性,并使其正常工作:
"sourceMaps": true,
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/dist/*",
"webpack:///src/*": "${webRoot}/dist/*"
}
}
完整的launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug React Run",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}/src",
"sourceMaps": true,
"breakOnLoad": true,
"sourceMapPathOverrides": {
"webpack:///./src/*": "${webRoot}/dist/*",
"webpack:///src/*": "${webRoot}/dist/*"
}
}
]
}
发布于 2021-04-18 11:20:26
您可能应该先标记断点,然后再启动调试器
https://stackoverflow.com/questions/62690455
复制相似问题