Issue 1:
Electron version: v1.3.3

Operating system :win 10 x64

Node version: v4.4.5

npm version: v2.15.5

I tried to debug my main process.

Just follow the Quick Start, and Debugging Doc

My command line:

"node_modules/.bin/electron" --debug-brk=5858 .

It then just run app while no debug-things happening.It seems the --debug-brk options didn't work.

I then try to compile node-inspector and another problem came up:

D:\elec-debug>"node_modules/.bin/node-pre-gyp" --target=1.3.3 --runtime=electron --fallback-to-build --directory node_modules/node-inspector/node_modules/v8-debug/ --dist-url=https://atom.io/download/atom-shell reinstall
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.6.29
node-pre-gyp info using node@4.4.5 | win32 | x64
node-pre-gyp info chdir node_modules/node-inspector/node_modules/v8-debug/
node-pre-gyp info check checked for "D:\elec-debug\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.7.7\electron-v1.3-win32-x64\debug.node" (not found)
node-pre-gyp http GET https://node-inspector.s3.amazonaws.com/debug/v0.7.7/electron-v1.3-win32-x64.tar.gz
node-pre-gyp http 404 https://node-inspector.s3.amazonaws.com/debug/v0.7.7/electron-v1.3-win32-x64.tar.gz
node-pre-gyp ERR! Tried to download: https://node-inspector.s3.amazonaws.com/debug/v0.7.7/electron-v1.3-win32-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for v8-debug@0.7.7 and electron@1.3.3 (electron-v1.3 ABI) (falling back to source compile with node-gyp)
node-pre-gyp http Pre-built binary not available for your system, looked for https://node-inspector.s3.amazonaws.com/debug/v0.7.7/electron-v1.3-win32-x64.tar.gz
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'node-gyp.cmd clean' (Error: spawn node-gyp.cmd ENOENT)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (D:\elec-debug\node_modules\node-pre-gyp\lib\util\compile.js:77:29)
node-pre-gyp ERR! stack at emitOne (events.js:77:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:169:7)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
node-pre-gyp ERR! stack at onErrorNT (internal/child_process.js:344:16)
node-pre-gyp ERR! stack at nextTickCallbackWith2Args (node.js:442:9)
node-pre-gyp ERR! stack at process._tickCallback (node.js:356:17)
node-pre-gyp ERR! System Windows_NT 10.0.10586
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\elec-debug\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "--target=1.3.3" "--runtime=electron" "--fallback-to-build" "--directory" "node_modules/node-inspector/node_modules/v8-debug/" "--dist-url=https://atom.io/download/atom-shell" "reinstall"
node-pre-gyp ERR! cwd D:\elec-debug\node_modules\node-inspector\node_modules\v8-debug
node-pre-gyp ERR! node -v v4.4.5
node-pre-gyp ERR! node-pre-gyp -v v0.6.29
node-pre-gyp ERR! not ok
Failed to execute 'node-gyp.cmd clean' (Error: spawn node-gyp.cmd ENOENT)

After that I tried to download electron-v1.3-win32-x64.tar.gz manually from chrome and it failed with a message:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
<Key>debug/v0.7.7/electron-v1.3-win32-x64.tar.gz</Key>
<RequestId>38C59D12A7CA4B80</RequestId>
<HostId>
XoNYuGC1Cacwa9wVT6d/lW4Oyj99RQQJWPzRqBSdnva6o7qHs3c94at0NiOjiBDq206ZfyDfad4=
</HostId>
</Error>

First question, is node-inspector necessary to debug electron?

And how can I debug electron main process now?

Issue 2:
Electron version: 1.3.0

Operating system: OS X 10.11.6

I'm trying to use VSCode to debug Electron's main process.

So I cloned https://github.com/electron/electron-quick-start

Setup VSCode debugging in .vscode/launch.json.

{
"version": "0.2.0",
"configurations": [
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": 5858,
"sourceMaps": false
}
]

Now I run ./node_modules/.bin/electron --debug-brk=5858 main.js, then using VSCode to attach to the process.

main.js (simplified from electron/electron-quick-start):

const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow // BREAKPOINT

let mainWindow

function createWindow () {
mainWindow = new BrowserWindow({width: 800, height: 600}) // BREAKPOINT

mainWindow.loadURL(`file://${__dirname}/index.html`)

mainWindow.on('closed', function () {
mainWindow = null
})
}

app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') { app.quit() }
})

app.on('activate', function () {
if (mainWindow === null) { createWindow() }
})

VSCode attaches correctly, but it misses the two breakpoints in the initial run.

However, if I then close the Renderer window, and click the dock icon again, I'm able to hit the breakpoint in createWindow.

I'm expecting with --debug-brk=5858, it should break on this line:

const electron = require('electron')

And then after attaching the process, I should be able to step through from there.

But Electron just goes on to create the Renderer window.

Any idea how I can get it to stop at the first line of script, as the documentation says?