javascript-在Chrome和vscode中调试nextjs应用

前端之家收集整理的这篇文章主要介绍了javascript-在Chrome和vscode中调试nextjs应用 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我已将此片段插入launch.json文件中.它总是打开chrome并停留在about:blank,然后v​​scode给出超时错误.我按照此处的步骤构建了launch.json文件.
https://github.com/Microsoft/vscode-recipes/tree/master/Next-js并对其进行了修改,使其可以用于chrome canary.

{
    "version": "0.2.0","configurations": [
        {
            "name": "Chrome Canary","type": "chrome","request": "launch","url": "http://localhost:3000/","runtimeExecutable": "C:/Users/myusername/AppData/Local/Google/Chrome SxS/Application/chrome.exe","webRoot": "${workspaceFolder}"
        },{
            "type": "node","name": "Next: Node","runtimeExecutable": "next","runtimeArgs": [
                "--inspect"
            ],"port": 9229,"console": "integratedTerminal"
        }
    ],"compounds": [
        {
            "name": "Next: Full","configurations": [
                "Next: Node","Chrome Canary"
            ]
        }
    ]
}
最佳答案
在没有自定义服务器的情况下调试Nextjs程序,请使用以下配置:

{
  "type": "node","name": "Launch via NPM","runtimeExecutable": "${workspaceFolder}\\node_modules\\.bin\\next","env": {
    "NODE_OPTIONS": "--inspect"
  }
}

使用自定义服务器调试Nextjs程序,使用配置:

{
  "type": "node","program": "${workspaceFolder}/server.js","runtimeArgs": [
      "--inspect"
  ],"console": "integratedTerminal"
}
原文链接:https://www.f2er.com/js/531169.html

猜你在找的JavaScript相关文章