question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to set breakpoints for nextjs app

See original GitHub issue

I’m trying to debug my nextjs app with Firefox.

I managed to debug it with chrome.

The error is that firefox can’t find the files. I already tried to add pathMappings but that is a lot to do and it still does not find components that are used inside these mappings. Besides that: the chrome extension does not need these path mappings.

// 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:3000/",
            "webRoot": "${workspaceFolder}",
            "pathMappings": [
                {"url": "/", "path": "${workspaceFolder}/pages/index.tsx"}
            ]
        },
        {
            "type": "chrome",
            "request": "launch",
            "name": "Chrome",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}"
        },
        {
            "type": "node",
            "request": "attach",
            "name": "Server",
            "port": 9229
        }
    ],
    "compounds": [
        {
            "name": "QLS: FullChrome",
            "configurations": ["Server", "Chrome"]
        },
        {
            "name": "QLS: FullFirefox",
            "configurations": ["Server", "Firefox"]
        }
    ]
}

With the specified pathMappings I can set breakpoints in index.tsx

My demo repo: https://github.com/Naxos84/nextjs-firefox-debug-demo

node version: 12.16.0 npm version: 6.13.4 vscode: 1.45.1 OS: windows 10

If you need any additional info please let me know.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
thirascommented, Feb 4, 2021

@hbenl The issue still exists. Please test it again with https://github.com/vercel/next-learn-starter/tree/master/demo

I’m migrating to Chrome right now. This extension is completely broken with Next.js. @Naxos84’s path mapping doesn’t work. The extension offers to add some mapping and they don’t work too

      "pathMappings": [
        {
          "url": "webpack://_n_e/pages",
          "path": "${workspaceFolder}/pages"
        },
        {
          "url": "webpack://_n_e/components",
          "path": "${workspaceFolder}/components"
        }
      ]

Please also try against any breakpoint that calls other than a page of component (for example a lib). In some cases, I’ve able to debug against some components but totally unstable

0reactions
deshiknavescommented, Nov 1, 2022

Yeah, this is my experience too. Chrome works fine, but the pathMapping on this just doesn’t work with a nextjs app

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Features: Debugging - Next.js
Debug your Next.js app. ... You can also press Ctrl + P on Windows/Linux or ⌘ + P on macOS to search for...
Read more >
How/where to set breakpoints in NextJS app? - Stack Overflow
1 Answer 1 · In the Sources pane of devtools, press CTRL-P and write the name of the file you want to debug,...
Read more >
nextjs - # - debugging - # - vscode - # - devtools
When fully setup, you'll be able to put breakpoints in both frontend (React) and backend code (Node.js, API routes). Then your favorite debugger...
Read more >
Debugging Next.js Applications - elliott.dev
It's often more effective to use a step-through debugger to pause and inspect your code as it executes. This is especially true when:...
Read more >
Running and debugging Node.js | WebStorm Documentation
js applications. You can put breakpoints right in your JavaScript or TypeScript code so you no longer need any debugger and console.log() ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found