throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try

问题:

cmd命令下执行Electron -v直接报如下错误:
D:\nvm\v16.14.2\node_modules\electron\index.js:17
throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try installing again’);
^

D:\nvm\v16.14.2\node_modules\electron\index.js:17
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
    ^

throw new Error(‘Electron failed to install correctly, please delete node_modules/electron and try_第1张图片

解决方案:

根据提示
1、删除node_modules/electron,这个node_modules在你全局安装nodejs的目录下
2、设置系统环境
// windows 请在环境变量里面设置,mac 请在环境变量文件中设置
ELECTRON_MIRROR=http://npm.taobao.org/mirrors/electron/
3、重新安装

npm install electron

你可能感兴趣的:(electron,javascript,前端)