npm run dev启动项目,electron提示throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')

 npm run dev projects, tips

throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')

Follow the prompts to delete electron package, reinstall, or an error

 

Separate installation electron

npm install electron -g
C:\Users\pxm\AppData\Roaming\npm\electron -> C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\cli.js

> core-js@3.6.4 postinstall C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
> https://opencollective.com/core-js
> https://www.patreon.com/zloirock

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)


> electron@8.0.3 postinstall C:\Users\pxm\AppData\Roaming\npm\node_modules\electron
> node install.js

(node:20768) UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found) for http://npm.taobao.org/mirrors/electron/v8.0.3/electron-v8.0.3-win32-x64.zip
    at EventEmitter.<anonymous> (C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\node_modules\got\source\as-stream.js:35:24)
    at EventEmitter.emit (events.js:311:20)
    at module.exports (C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\node_modules\got\source\get-response.js:22:10)
    at ClientRequest.handleResponse (C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\node_modules\got\source\request-as-event-emitter.js:155:5)
    at Object.onceWrapper (events.js:418:26)
    at ClientRequest.emit (events.js:323:22)
    at ClientRequest.origin.emit (C:\Users\pxm\AppData\Roaming\npm\node_modules\electron\node_modules\@szmarczak\http-timer\source\index.js:37:11)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:603:27)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:119:17)
    at Socket.socketOnData (_http_client.js:476:22)
(node:20768) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:20768) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
+ electron@8.0.3
added 85 packages from 93 contributors in 67.606s

 

 

Tip http://npm.taobao.org/mirrors/electron/v8.0.3/electron-v8.0.3-win32-x64.zip inaccessible

Items used in electron version v7.1.14, nor tried https://npm.taobao.org/mirrors/electron/v7.1.14/electron-v7.1.14-win32-x64.zip

Taobao electron image, to find electron-bit window 64, the corresponding address is https://cdn.npm.taobao.org/dist/electron/7.1.14/electron-v7.1.14-win32-x64.zip

 

 The reason is that it addresses the problem, resulting in the above error

 

The official also give reasons: Taobao image problem

 

 

 At the same time the solution given by the official

For example, the use of Chinese Mirror:

ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/"

 

A mirror disposed electron source address:

npm config set electron_mirror https://cdn.npm.taobao.org/dist/electron/

 

 

reference:

Electron 8.0.2 Install Failed Because Of Wrong Download URL Path #22480

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

Electron 文档-安装

淘宝electron镜像

Guess you like

Origin www.cnblogs.com/Zev_Fung/p/12421858.html