【React】Debugging for Next.JS
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
本作品采用 知识共享署名-非商业性使用 2.5 中国大陆许可协议进行许可。 |