Error: Electron failed to install correctly, please delete node_modules/electron and try installing

错误信息

有可能是electron升级的原因,执行npm run electron后,控制台提示抛出异常:

Electron failed to install correctly, please delete node_modules/electron and try installing again

解决方法

1、npm ls electron查询本地electron 的版本号
2、前往淘宝镜像https://npm.taobao.org/mirrors/electron手动下载对应版本的electrong包
3、在node_modules\electron\下创建dist文件夹,将下载的压缩包解压进刚刚创建的dist目录
4、在node_modules\electron\中创建path.txt,内容为electron.exe

解决方案来自这位老哥,他还提供者第二种方法,感兴趣的可以看下:https://blog.csdn.net/u013584271/article/details/102764898


版权声明:本文为Dominic_W原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。