最新版本可能存在问题。这种情况要去npm官网查看electron的版本记录选择一个不是最新的版本进行安装。:
这里我是:然后成功了
cnpm install -g electron@3.1.0
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 (E:\electronjsTest\node_modules\_electron@7.0.0@electron\index.js:14:11)
at Object.<anonymous> (E:\electronjsTest\node_modules\_electron@7.0.0@electron\index.js:18:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (modu