throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try installing again’)
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (D:\AppServ\www\electron-project\practice\[email protected]@electron\index.js:14:11)
at Object. (D:\AppServ\www\electron-project\practice\[email protected]@electron\index.js:18:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions…js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (D:\AppServ\www\electron-project\practice\[email protected]@electron\cli.js:3:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: electron .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start 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:\Users\Administrator\AppData\Roaming\npm-cache_logs\2019-07-28T15_39_25_139Z-debug.log
可能存在两种情况
-
需要删除node_modules/electron的安装包,然后再重新npm install,重新安装包即可。
-
如果第一种方法常识无效,那么很可能是相关依赖包没有完全下载完全,建议删除node_modules后再使用yarn来下载依赖包,步骤如下:
- 删除node_modules
- 安装全局yarn: npm install yarn -g
- 安装项目依赖: yarn install
- 安装electron: yarn install electron --save
- 重新启动程序: electron .
如图: