首页 > 其他分享 >【React】Debugging for Next.JS

【React】Debugging for Next.JS

时间:2024-11-20 16:09:55浏览次数:1  
标签:node Debugging launch JS inspect Next React js type

1.Create a file named .vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Next.js: debug server-side",
      "type": "node-terminal",
      "request": "launch",
      "command": "npm run dev"
    },
    {
      "name": "Next.js: debug client-side",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:3000"
    },
    {
      "name": "Next.js: debug client-side (Firefox)",
      "type": "firefox",
      "request": "launch",
      "url": "http://localhost:3000",
      "reAttach": true,
      "pathMappings": [
        {
          "url": "webpack://_N_E",
          "path": "${workspaceFolder}"
        }
      ]
    },
    {
      "name": "Next.js: debug full stack",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/node_modules/.bin/next",
      "runtimeArgs": ["--inspect"],
      "skipFiles": ["<node_internals>/**"],
      "serverReadyAction": {
        "action": "debugWithEdge",
        "killOnServerStop": true,
        "pattern": "- Local:.+(https?://.+)",
        "uriFormat": "%s",
        "webRoot": "${workspaceFolder}"
      }
    }
  ]
}

 

2.Terminal

yarn add win-node-env

 

3.Terminal

set NODE_OPTIONS=--inspect

 

4.update the dev script on your package.json:

{
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev"
}
}

 

5.Open a new tab and visit chrome://inspect
6.Click inspect to open a separate DevTools window.

Configuring: Debugging | Next.js

标签:node,Debugging,launch,JS,inspect,Next,React,js,type
From: https://www.cnblogs.com/sekihin/p/18558619

相关文章