Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next.js example does not seem to work with next@^6.0.0.0 #103

Closed
nicolas-marien opened this issue May 17, 2018 · 17 comments
Closed

Next.js example does not seem to work with next@^6.0.0.0 #103

nicolas-marien opened this issue May 17, 2018 · 17 comments
Assignees

Comments

@nicolas-marien
Copy link

Hello,

I'm trying to debug Next.js applications, running with the latest version of next.js which is 6.0.3. But I did not manage to have my breakpoints recognized in the vscode node debugger.

To reproduce, you can clone nextgram and update next (also react and react-dom) to the latest version.

Here is my launch configuration. I changed the runtimeExecutable to use the local next installation:

{
    "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",
            "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/next",
            "runtimeArgs": [
                "--inspect"
            ],
            "port": 9229,
            "console": "integratedTerminal"
        }
    ],
    "compounds": [
        {
            "name": "Next: Full",
            "configurations": ["Next: Node", "Next: Chrome"]
        }
    ]
}

All my breakpoint are Unverified breakpoint, Breakpoints set but not yet bound so I assume this could be a source map issue.

I'm running MacOS 10.13.3 with Node v10.1.0 and npm 6.0.1.
Did someone experience a similar issue ❓
Thank you 😸

@timjbray
Copy link

Hello,
I have the same issue - same platform (MacOS) & latest Node, npm
Unverified breakpoint, Breakpoint ignored because generated code not found (source map problem?)
Thanks!

@frol
Copy link

frol commented May 26, 2018

The same issue here:

OS: Arch Linux, x64
VS Code 1.23.1
Node.js 10.2.1
Next.js 6.0.3
React 16.4.0

@jamesgibson14
Copy link

jamesgibson14 commented Jun 7, 2018

Same problem with launch.json:
MacOS
node: 8.11.1
"next": "^6.0.3",
"react": "^16.4.0",
"react-dom": "^16.4.0"

@timmywil
Copy link

timmywil commented Jun 7, 2018

Here are some notes that might help us figure out what's wrong. These are just things I noticed when trying to debug this issue.

  1. next.js 6 is using the babel core 7 beta. I don't mention this because I know of any issue with sourcemap creation in babel 7. I only mention it because there may be something different there. Sourcemaps have their own spec and should be unaffected, but you never know.

  2. I also noticed that while breakpoints set in vs code remain unverified, breakpoints on webpack sources do work when using Chrome devtools directly. Nevertheless, when the breakpoint is hit, vs code does break when devtools does, but while devtools breaks correctly on the source file, vs code breaks on the compiled index.js file.

@timmywil
Copy link

timmywil commented Jun 7, 2018

I was able to fix the issue for myself. I was staring at the source map for a while and noticed that the ./ was missing from the paths that didn't include node_modules (e.g. "webpack:///actions/index.js" instead of "webpack:///./actions/index.js"). I tried the following and it worked:

...
      "sourceMapPathOverrides": {
        ...
        "webpack:///*": "${webRoot}/*"
      },
...

I don't know if this is the proper fix. Maybe there is an issue in babel, next.js, webpack, or vs code, but this got breakpoints working again.

@leifdalan
Copy link

leifdalan commented Jun 7, 2018

@timmywil I build from the /src folder (next build src). From your solution, where would I append /src? I've tried a few things:

{
            "type": "chrome",
            "request": "launch",
            "name": "Next: Chrome",
            "url": "http://localhost:8000",
            "webRoot": "${workspaceFolder}/src",
            "sourceMapPathOverrides": {
                "webpack:///*": "${webRoot}/src/*"
            },

        },

and every permutation of adding/removing /src to webRoot and the webpack sourceMapPathOverrides. Any help/advice would be greatly appreciated! I miss my breakpoints.

@timmywil
Copy link

timmywil commented Jun 8, 2018

@leifdalan I'm not sure, but note that you should probably still keep the other default entries in sourceMapPathOverrides.

@auchenberg
Copy link
Contributor

Issue seems to be related to a change in next.js. I've opened an issue on their side: vercel/next.js#4571

@leifdalan
Copy link

@timmywil's fix worked for me. Thanks!

@nicolas-marien
Copy link
Author

@timmywil Thank, w/ your solution Chrome debugging worked. Still no luck for server side code, like getInitialProps. Thank @auchenberg for opening an issue on Next side.

@zerocity
Copy link

zerocity commented Jul 12, 2018

This is working for me on the server side and client side

{
          "type": "chrome",
          "request": "launch",
          "name": "Next: Chrome",
          "url": "http://localhost:3000",
          "webRoot": "${workspaceFolder}",
          "sourceMapPathOverrides": {
            "webpack:///*": "${webRoot}/*"
          },
      },
      {
          "type": "node",
          "request": "launch",
          "name": "Next: Node",
          "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/next",
          "runtimeArgs": [
              "--inspect"
          ],
          "sourceMapPathOverrides": {
            "webpack:///*": "${workspaceFolder}/*"
          },
          "port": 9229,
          "console": "integratedTerminal"
      }

@lipp
Copy link

lipp commented Oct 25, 2018

Trying the debug config for next.js 7. Still not working for Chrome. Breaking at random source lines. @zerocity config is not working for me.

Debugging in Chrome dev tools is working -> not sure it is a Next.js issue.

@justinphilpott
Copy link

justinphilpott commented Nov 8, 2018

I have the same issue, unpredictable code breaking, rather depressing!
@zerocity not working for me.

Any updates? Thanks! :)

@zerocity
Copy link

zerocity commented Nov 9, 2018

I tested the config on windows with next 7 and it works.
I changed only
"console": "integratedTerminal" ->
"console": "internalConsole"
i had some issues with WSL.
here is example repo https://github.com/zerocity/vscode-next-debugger-test

@MobinHiq
Copy link

MobinHiq commented Dec 6, 2018

Got the same issue, I tried everything and still does not work! It just randomly jumps over some line and breaks in some line that it doesn't have any breakpoints!

@zerocity
Copy link

zerocity commented Dec 7, 2018 via email

@auchenberg
Copy link
Contributor

Duplicate of #80

@auchenberg auchenberg marked this as a duplicate of #80 Feb 4, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests