ブラウザウィンドウ DevToolsのみ、レンダリングプロセススクリプトをデバッグすることができます。メインプロセスからスクリプトをデバッグする方法を提供するために、Electronは、--debug と --debug-brk スイッチを提供します。
Electronのメインプロセスをデバッグするために次のコマンドラインスイッチを使用します
このスイッチを使ったとき、Electronは、 port 上でV8デバッガープロトコルメッセージをリッスンします。デフォルトの port は 5858です。
--debug のようですが、最初の行でスクリプトをポーズします。
Note: Electron は今のところ、明確にはnode-inspectorは動作せず、node-inspectorのコンソール下で、process オブジェクトを調査した場合、メインプロセスはクラッシュするでしょう。
1. インストールされたnode-gyp required tools を確認する
2. node-inspectorをインストールする
$ npm install node-inspector$ npm install git+https://git@github.com/enlight/node-pre-gyp.git#detect-electron-runtime-in-find$ node_modules/.bin/node-pre-gyp --target=0.36.2 --runtime=electron --fallback-to-build --directory node_modules/v8-debug/ --dist-url=https://atom.io/download/atom-shell reinstall
$ node_modules/.bin/node-pre-gyp --target=0.36.2 --runtime=electron --fallback-to-build --directory node_modules/v8-profiler/ --dist-url=https://atom.io/download/atom-shell reinstallHow to install native modulesを見る。
デバッグフラッグでElectronを開始する:
$ electron --debug=5858 your/appまたは、最初のライン上でスクリプトをポーズする:
$ electron --debug-brk=5858 your/app6. Electronを使用して、node-inspector サーバーを開始する
$ ELECTRON_RUN_AS_NODE=true path/to/electron.exe node_modules/node-inspector/bin/inspector.jsChromeブラウザで、 http://127.0.0.1:8080/debug?ws=127.0.0.1:8080&port=5858 を開きます。エントリーラインを見るために、debug-brkを始めるには、ポーズをクリックします。