Anatoly Strashkevich
Anatoly Strashkevich

Reputation: 1914

Debug electron with vscode. runtimeExecutable

I can't debug electron main process on windows with vscode. I've tried all possible launch.json configurations i could find, but app object is always undefined. Application works, i have problem only with debugging. It seems like my runtimeExecutable path is wrong. I've tried https://discuss.atom.io/t/debugging-electron-api-demo-using-visual-studio-code/40661/2 I've took current configuration from docs https://github.com/electron/electron/blob/master/docs/tutorial/debugging-main-process-vscode.md

my launch.json

{
  "version": "0.2.0",
  "configurations": [
    { 
      "name": "Debug Main Process",
      "type": "node",
      "request": "launch",
      "program": "${workspaceRoot}/app/main.ts",
      "stopOnEntry": false,
      "args": ["."],  
      "cwd": "${workspaceRoot}",
      "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
      "outFiles": [  
        "${workspaceRoot}/dist/main.js"
      ],
      "env": { }, 
      "sourceMaps": true 
    }   
  ]
} 

Thank you. enter image description here

Upvotes: 2

Views: 1688

Answers (1)

Anatoly Strashkevich
Anatoly Strashkevich

Reputation: 1914

According to docs https://code.visualstudio.com/docs/nodejs/nodejs-debugging Inspector protocol is not yet supported for electron.

This is working configurations. Should have been adding protocol legacy.

  {
      "version": "0.2.0",
      "configurations": [
        { 
          "name": "Debug Main Process",
          "type": "node",
          "request": "launch",
          "program": "${workspaceRoot}/app/main.ts",
          "stopOnEntry": false,
          "args": ["."],  
          "cwd": "${workspaceRoot}",
          "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd",
          "outFiles": [  
            "${workspaceRoot}/dist/main.js"
          ],
          "protocol":"legacy",
          "env": { }, 
          "sourceMaps": true 
        }   
      ]
    } 

Upvotes: 1

Related Questions