Electron 初始化

mkdir my-electron-app && cd my-electron-app
npm init -y
npm i --save-dev electron

npm install.js 报错

> electron@12.0.7 postinstall D:javascriptplaybill
ode_moduleselectron
> node install.js

RequestError: read ECONNRESET
    at ClientRequest.<anonymous> (D:javascriptplaybill
ode_modulesgotsource
equest-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:421:26)
    at ClientRequest.emit (events.js:326:22)
    at ClientRequest.origin.emit (D:javascriptplaybill
ode_modules@szmarczakhttp-timersourceindex.js:37:11)
    at TLSSocket.socketErrorListener (_http_client.js:469:9)
    at TLSSocket.emit (events.js:314:20)
    at emitErrorNT (internal/streams/destroy.js:100:8)
    at emitErrorCloseNT (internal/streams/destroy.js:68:3)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
npm WARN playbill@1.0.0 No description

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@12.0.7 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron@12.0.7 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersAdministratorAppDataRoaming
pm-cache\_logs2021-05-09T12_40_24_916Z-debug.log

解决方案:

npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver

DEMO

https://github.com/electron/electron/tree/v12.0.6/docs/fiddles/quick-start
原文地址:https://www.cnblogs.com/rubekid/p/14748909.html