Comments (12)
I spent many hours searching for an answer to this because I was running into the same problem. I finally found the solution for my set up here.
Here’s what did the trick for me:
Create a file in the root of your frontend called next.config.js
and put the following code:
module.exports = {
webpack(config) {
config.devtool = 'eval-source-map';
return config;
},
};
Now you should be able to set breakpoints on client side functions like onChange callbacks or onSubmit, etc.
For reference, my launch.json
file...
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Next: Chrome",
"url": "http://localhost:7777",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/next",
"runtimeArgs": [
"-p",
"7777"
],
"port": 5622,
"env": {
"NODE_OPTIONS": "--inspect=5622"
}
}
],
"compounds": [
{
"name": "Next: Full",
"configurations": [
"Next: Node",
"Next: Chrome"
]
}
]
}
from vscode-recipes.
I'm having the same issue.
Versions of node, npm, and next:
$ node --version
v10.15.3
$ npm --version
6.9.0
$ npm list next
[email protected] /Users/delingren/scratchpad/next-exercise
└── [email protected]
I took a look at node_modules/.bin/next (it's just a js file without the extension), and it explicitly throws when passed --inspect:
if (args['--inspect'])
throw new Error(`Use env variable NODE_OPTIONS instead: NODE_OPTIONS="--inspect" next ${command}`);
So I modified launch.json and the following works for me:
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"program": "${workspaceFolder}/node_modules/.bin/next",
"runtimeArgs": ["--inspect"],
"port": 9229,
"console": "integratedTerminal"
}
from vscode-recipes.
It works on backend, but no on frontend for me.
from vscode-recipes.
Is there any update to this? I'm not able to debug my app...
from vscode-recipes.
What version of Node and Next are you using @ahoyahoy? Looks like you are running node --inspect koa
and not next
from vscode-recipes.
I have this same problem while using express and yes we have to run node server.js --inspect
instead of next
. I'm using node version 10.4.1 and next v6.0.3. I'm be happy to open a bug on next.js if that's where the problem lies.
from vscode-recipes.
We are tracking an issue with Next 6 here vercel/next.js#4571
from vscode-recipes.
I have same error with cross-env NODE_ENV=development nodemon --inspect server/server.js
from vscode-recipes.
Me too. It's working for Next: Node but not kicking in for Next: Chrome.
Please see my config below:
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Next: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"program": "${workspaceFolder}/src/server.js",
"runtimeArgs": [
"--inspect",
],
"protocol": "inspector",
"port": 9229,
"console": "integratedTerminal",
"autoAttachChildProcesses": true,
},
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"stopOnEntry": false,
"restart": true
}
],
"compounds": [
{
"name": "Next: Full",
"configurations": [
"Next: Node",
"Next: Chrome"
]
}
]
}
from vscode-recipes.
Hey there, I created a PR on Next.js docs to have Next.js debugging working in either Chrome DevTools or VSCode, appreciate any feedback you have when trying it out on the PR: https://github.com/zeit/next.js/pull/10807/files?short_path=bfcc096#diff-bfcc096377efef455dd348d059704209
I choosed to only attach to the debugger from VSCode instead of trying to completely launch next from VSCode because in many occasions your Next.js application might be loaded by docker/overmind/foreman/heroku local... Let me know what you think!
from vscode-recipes.
Well I am using nextjs 9 and I was able to debug my app in vscode/chrome.
I installed the "Debugger for Chrome" extension.
I'm still struggeling to use Firefox cause "Debugger for Firefox" tells me that it can't find the files...
Launch.json
{
// 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": "firefox",
"request": "launch",
"reAttach": true,
"name": "Firefox",
"url": "http://localhost/",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "launch",
"name": "Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "attach",
"name": "Server",
"port": 9229
}
],
"compounds": [
{
"name": "FullChrome",
"configurations": ["Server", "Chrome"]
},
{
"name": "FullFirefox",
"configurations": ["Server", "Firefox"]
}
]
}
I am starting my app with cross-env TS_NODE_PROJECT=tsconfig.server.json nodemon --exec node --inspect-brk -r ts-node/register server/index.ts
Maybe this helps someone and maybe someone knows how to do this for firefox.
from vscode-recipes.
The next.js recipe has been updated
from vscode-recipes.
Related Issues (20)
- cloud not connect to debug target HOT 3
- Cannot connect to the target at localhost:9223. Could not connect to debug target at .. Promise was caceled.
- Can't debug in vscode with use preview javascript debugger and old debuger takes minutes to hit a break point HOT 1
- ERR: code ENOENT - looking package.json under desktop HOT 3
- debuggerPort does not work for Ruby on Rails debugging in VS Cod HOT 1
- Does not work for TypeScript HOT 1
- The conflict between this document and the vscode official document
- NextJS debugging recipe not working / needs updating. HOT 1
- Broken Link in README.md HOT 1
- Rails server terminates threads when debugging without WEB_CONCURRENCY=0
- Vue Cli Recipe Does not work when using TS with vue HOT 2
- I Can't Debug vue.js When "preLaunchTask" is added in launch.json
- Debug Jest Tests recipe fails on Mac HOT 1
- npm run debug fails
- GCC fatal error occurred
- The task 'vuejs: start' cannot be tracked. HOT 1
- Angular inside electron
- VScode debug EJS files of HEXO theme?
- The angular recipe doesn't work for Angular 15+
- `attach` configuration for Nodemon HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-recipes.