最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node js debugging not working in Visual Studio code (year 2020) - Stack Overflow

programmeradmin2浏览0评论

I have gone though similar questions and none of the answers help perhaps because the configurations have changed in the latest VS Code or they are not relavant.

I get this error when I try to launch:

Exception has occurred: ReferenceError
ReferenceError: closeDescriptionPopup is not defined
    at HTMLParagraphElement.eval (eval at E (chrome-error://chromewebdata/:14:208), <anonymous>:3:21)
    at w (chrome-error://chromewebdata/:4622:845)
    at L.b (chrome-error://chromewebdata/:4628:231)
    at L.e (chrome-error://chromewebdata/:4627:393)
    at window.jstProcess (chrome-error://chromewebdata/:4630:800)
    at chrome-error://chromewebdata/:4632:56

My launch.json looks like this. Please note that this has become like this due to various trial and errors:

   {
    "configurations": [
        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "pwa-chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}",
            
        },
        {
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "request": "attach",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "pwa-node"
        },
    {
        "name": "Attach to Chrome",
        "port": 9222,
        "request": "attach",
        "type": "pwa-chrome",
        "webRoot": "${workspaceFolder}",
    }
    ]
}

I have tried various combination of this as well:

 node --inspect-brk  --inspect app.js

Sometimes it gives a message the dubugger is running at ws://somehexadisgits but the break points do not hit.

P.S This is my vs code version:

 Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363

I have gone though similar questions and none of the answers help perhaps because the configurations have changed in the latest VS Code or they are not relavant.

I get this error when I try to launch:

Exception has occurred: ReferenceError
ReferenceError: closeDescriptionPopup is not defined
    at HTMLParagraphElement.eval (eval at E (chrome-error://chromewebdata/:14:208), <anonymous>:3:21)
    at w (chrome-error://chromewebdata/:4622:845)
    at L.b (chrome-error://chromewebdata/:4628:231)
    at L.e (chrome-error://chromewebdata/:4627:393)
    at window.jstProcess (chrome-error://chromewebdata/:4630:800)
    at chrome-error://chromewebdata/:4632:56

My launch.json looks like this. Please note that this has become like this due to various trial and errors:

   {
    "configurations": [
        {
            "name": "Launch Chrome",
            "request": "launch",
            "type": "pwa-chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}",
            
        },
        {
            "name": "Attach by Process ID",
            "processId": "${command:PickProcess}",
            "request": "attach",
            "skipFiles": [
                "<node_internals>/**"
            ],
            "type": "pwa-node"
        },
    {
        "name": "Attach to Chrome",
        "port": 9222,
        "request": "attach",
        "type": "pwa-chrome",
        "webRoot": "${workspaceFolder}",
    }
    ]
}

I have tried various combination of this as well:

 node --inspect-brk  --inspect app.js

Sometimes it gives a message the dubugger is running at ws://somehexadisgits but the break points do not hit.

P.S This is my vs code version:

 Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
Share Improve this question edited Jul 2, 2020 at 8:36 ABGR asked Jul 2, 2020 at 8:02 ABGRABGR 5,2054 gold badges31 silver badges55 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 11

After a few hours of frustrations this is how I solved.

  1. Remove everything in launch.json to completely make it blank so that the button Run and Debug becomes visible like this.

(Earlier a dropdown was showing with the list of configurations that were added in the launch json)

  1. Hit the button Run and Debug and select any environment. I selected (chrome). Now in the terminal run npm start. Notice the dropdown on the terminal at the bottom. It would have selected JavaScript Debug Terminal
  1. Put the breakpoints anywhere, hit the API (through postman or browser get request) and notice the joy of happiness within you when it hits the breakpoint.

P.S later on when you don't want to run the app everytime in debug, you may select the other option in the terminal for. e.g select default shell/powershell, Now when you run npm start it will start with the environment in normal node environment and will run normally without attaching itself in the debug environment. So this is how you may switch between choosing your application to run in debug environment or without it by selecting any of these options from the drop-down in the VS terminal.

I was running node js debugger and @ABGR's answer wasn't working for me.

Debugger was on but breakpoints were not working. What worked for me was removing the contents of launch.json and adding a new configuration by selecting Add configuration:

Attach by process Id

After this you can start your node app using whatever command you use to start the app.

And after the app has started, you can start the debugger by clicking on the run/debug icon.

Drop-down will appear on the screen and you will be able to select the process id for the node app which has started. You may have to select one of the other process IDs from the drop-down if one doesn't work.

Breakpoints will work post this process.

发布评论

评论列表(0)

  1. 暂无评论