Sunday, 9 April 2017

Debugging Electron in VSCode

I'm using Visual Studio Code as an editor and I'm trying to debug my Electron app. The default snippet for an Electron launch script in the launch.json file looks like this:

{
    // Use IntelliSense to learn about possible Node.js debug 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": "node",
            "request": "launch",
            "name": "Electron Main",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron",
            "windows": {
                "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/electron.cmd"
            },
            "program": "${workspaceRoot}/main.js",
            "protocol": "legacy"
        }
    ]
}

But when I try and run it, I get an error:

/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/.bin/electron --debug-brk=5069 --nolazy main.js 
App threw an error during load
Error: Cannot find module '/Users/Hum4n01d/Desktop/Tech/Electron/Project/--debug-brk=5069'
    at Module._resolveFilename (module.js:470:15)
    at Function.Module._resolveFilename (/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/electron/dist/Electron.app/Contents/Resources/electron.asar/common/reset-search-paths.js:35:12)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at init (/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/electron-compile/lib/config-parser.js:292:16)
    at main (/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/electron-prebuilt-compile/lib/es6-init.js:40:29)
    at Object.<anonymous> (/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/electron-prebuilt-compile/lib/es6-init.js:43:1)
    at Object.<anonymous> (/Users/Hum4n01d/Desktop/Tech/Electron/Project/node_modules/electron-prebuilt-compile/lib/es6-init.js:45:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)

Apparently it's trying to run the project at /Users/Hum4n01d/Desktop/Tech/Electron/Project/--debug-brk=5069 but obviously that isn't a thing! It's combining the directory and the flag :(



via Hum4n01d

No comments:

Post a Comment