W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
瀏覽器窗口的開發(fā)工具僅能調(diào)試渲染器的進程腳本(比如 web 頁面)。為了提供一個可以調(diào)試主進程的方法,Electron 提供了 --debug
和 --debug-brk
開關。
使用如下的命令行開關來調(diào)試 Electron 的主進程:
--debug=[port]
當這個開關用于 Electron 時,它將會監(jiān)聽 V8 引擎中有關 port
的調(diào)試器協(xié)議信息。默認的 port
是 5858
。
--debug-brk=[port]
就像 --debug
一樣,但是會在第一行暫停腳本運行。
備注: Electron 目前對 node-inspector 支持的不是特別好,如果你通過 node-inspector 的 console 來檢查 process
對象,主進程就會崩潰。
$ npm install node-inspector
node-pre-gyp
的一個修訂版$ npm install git+https://git@github.com/enlight/node-pre-gyp.git#detect-electron-runtime-in-find
node-inspector
v8
模塊(將 target 參數(shù)修改為你的 Electron 的版本號)$ 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 reinstall
[How to install native modules][how-to-install-native-modules].
你也可以用調(diào)試參數(shù)來運行 Electron :
$ electron --debug=5858 your/app
或者,在第一行暫停你的腳本:
$ electron --debug-brk=5858 your/app
$ ELECTRON_RUN_AS_NODE=true path/to/electron.exe node_modules/node-inspector/bin/inspector.js
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: