<ul dir="auto">
<li>Electron version: v1.3.3</li>
<li>Operating system :win 10 x64</li>
<li>Node version: v4.4.5</li>
<li>npm version: v2.15.5</li>
</ul>
<p dir="auto">I tried to debug my main process.</p>
<p dir="auto">Just follow the <a href="http://electron.atom.io/docs/tutorial/quick-start/#quick-start" rel="nofollow">Quick Start</a>, and <a href="http://electron.atom.io/docs/tutorial/debugging-main-process/#command-line-switches" rel="nofollow">Debugging Doc</a></p>
<p dir="auto">My command line:<br>
<code class="notranslate">"node_modules/.bin/electron" --debug-brk=5858 .</code><br>
It then just run app while no debug-things happening.It seems the --debug-brk options didn't work.</p>
<p dir="auto">I then try to <a href="http://electron.atom.io/docs/tutorial/debugging-main-process/#use-node-inspector-for-debugging" rel="nofollow">compile node-inspector</a> and another problem came up:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="D:\elec-debug&gt;&quot;node_modules/.bin/node-pre-gyp&quot; --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 &quot;D:\elec-debug\node_modules\node-inspector\node_modules\v8-debug\build\debug\v0.7.7\electron-v1.3-win32-x64\debug.node&quot; (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.&lt;anonymous&gt; (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 &quot;C:\\Program Files\\nodejs\\node.exe&quot; &quot;D:\\elec-debug\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp&quot; &quot;--target=1.3.3&quot; &quot;--runtime=electron&quot; &quot;--fallback-to-build&quot; &quot;--directory&quot; &quot;node_modules/node-inspector/node_modules/v8-debug/&quot; &quot;--dist-url=https://atom.io/download/atom-shell&quot; &quot;reinstall&quot;
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)"><pre class="notranslate"><code class="notranslate">D:\elec-debug&gt;"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.&lt;anonymous&gt; (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)
</code></pre></div>
<p dir="auto">After that I tried to download <em>electron-v1.3-win32-x64.tar.gz</em> manually from chrome and it failed with a message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;Error&gt;
&lt;Code&gt;NoSuchKey&lt;/Code&gt;
&lt;Message&gt;The specified key does not exist.&lt;/Message&gt;
&lt;Key&gt;debug/v0.7.7/electron-v1.3-win32-x64.tar.gz&lt;/Key&gt;
&lt;RequestId&gt;38C59D12A7CA4B80&lt;/RequestId&gt;
&lt;HostId&gt;
XoNYuGC1Cacwa9wVT6d/lW4Oyj99RQQJWPzRqBSdnva6o7qHs3c94at0NiOjiBDq206ZfyDfad4=
&lt;/HostId&gt;
&lt;/Error&gt;"><pre class="notranslate"><code class="notranslate">&lt;Error&gt;
&lt;Code&gt;NoSuchKey&lt;/Code&gt;
&lt;Message&gt;The specified key does not exist.&lt;/Message&gt;
&lt;Key&gt;debug/v0.7.7/electron-v1.3-win32-x64.tar.gz&lt;/Key&gt;
&lt;RequestId&gt;38C59D12A7CA4B80&lt;/RequestId&gt;
&lt;HostId&gt;
XoNYuGC1Cacwa9wVT6d/lW4Oyj99RQQJWPzRqBSdnva6o7qHs3c94at0NiOjiBDq206ZfyDfad4=
&lt;/HostId&gt;
&lt;/Error&gt;
</code></pre></div>
<p dir="auto">First question, is <em>node-inspector</em> necessary to debug electron?<br>
And how can I debug electron main process now?</p>
<ul dir="auto">
<li>Electron version: 1.3.0</li>
<li>Operating system: OS X 10.11.6</li>
</ul>
<p dir="auto">I'm trying to use VSCode to debug Electron's main process.</p>
<p dir="auto">So I cloned <a href="https://github.com/electron/electron-quick-start">https://github.com/electron/electron-quick-start</a><br>
Setup VSCode debugging in <code class="notranslate">.vscode/launch.json</code>.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;version&quot;: &quot;0.2.0&quot;,
  &quot;configurations&quot;: [
    {
      &quot;name&quot;: &quot;Attach&quot;,
      &quot;type&quot;: &quot;node&quot;,
      &quot;request&quot;: &quot;attach&quot;,
      &quot;port&quot;: 5858,
      &quot;sourceMaps&quot;: false
    }
  ]"><pre class="notranslate"><code class="notranslate">{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach",
      "type": "node",
      "request": "attach",
      "port": 5858,
      "sourceMaps": false
    }
  ]
</code></pre></div>
<p dir="auto">Now I run <code class="notranslate">./node_modules/.bin/electron --debug-brk=5858 main.js</code>, then using VSCode to attach to the process.</p>
<h3 dir="auto">main.js (simplified from <code class="notranslate">electron/electron-quick-start</code>):</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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() }
})"><pre class="notranslate"><code class="notranslate">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() }
})
</code></pre></div>
<p dir="auto">VSCode attaches correctly, but it misses the two breakpoints in the initial run.<br>
However, if I then close the Renderer window, and click the dock icon again, I'm able to hit the breakpoint in <code class="notranslate">createWindow</code>.</p>
<p dir="auto">I'm expecting with <code class="notranslate">--debug-brk=5858</code>, it should break on this line:<br>
<code class="notranslate">const electron = require('electron')</code><br>
And then after attaching the process, I should be able to step through from there.<br>
But Electron just goes on to create the Renderer window.<br>
Any idea how I can get it to stop at the first line of script, as the documentation says?</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/4033249/17127918/f3a13696-52bd-11e6-8e99-029cd23dae5b.png"><img width="851" alt="screen shot 2016-07-25 at 11 17 09 pm" src="https://cloud.githubusercontent.com/assets/4033249/17127918/f3a13696-52bd-11e6-8e99-029cd23dae5b.png" style="max-width: 100%;"></a></p>