我正在使用 Visual Studio Code (vscode) 开发一个 next.js 应用程序,我非常喜欢这个编辑器!我已经从扩展商店安装了 Chrome 调试器。下面的配置启动了一个新的 Chrome 实例,我可以开始调试。它停在 vscode 的断点处,但问题来了。尽管我将其添加到“skipfiles”,但它不显示函数的值并跳转到 node_modules 事件。 断点也不会在构造函数上停止。 next.js 是否不被支持? 我经常使用 async wait 语法。调试服务器端代码运行良好。
{
"name": "My Client",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceRoot}/my-client/",
"skipFiles": [
"node_modules/**/*.js",
"<node_internals>/**/*.js",
"node_modules",
".next"
]
}
最佳答案
以下内容对我有用(扩展自马克西米利亚诺·塞斯佩德斯的回答):
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [{
"type": "node",
"request": "launch",
"name": "NPM Launch",
"runtimeExecutable": "npm",
"cwd": "${workspaceFolder}/my-app",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229,
"console": "integratedTerminal"
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"stopOnEntry": false,
"restart": true
},
{
"type": "chrome",
"request": "launch",
"name": "Chrome",
"url": "http://localhost:4200",
"webRoot": "${workspaceRoot}"
}
],
"compounds": [{
"name": "Debug-Full",
"configurations": ["NPM Launch", "Attach", "Chrome"]
}]
}
关于javascript - next.js 应用程序的 vscode 启动配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46018150/