npm和yarn包管理器报错
提示:这里描述项目中遇到的问题:
运行yarn install安装electron报错:
D:\Javaproject(idea)\electron-project0>yarn install
yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error D:\Javaproject(idea)\electron-project0\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: D:\Javaproject(idea)\electron-project0\node_modules\electron
Output:
Error: Generated checksum for "electron-v19.0.12-win32-x64.zip" did not match expected checksum.
at Hash.<anonymous> (D:\Javaproject(idea)\electron-project0\node_modules\sumchecker\index.js:133:20)
at Hash.emit (node:events:513:28)
at emitReadable_ (node:internal/streams/readable:590:12)
at onEofChunk (node:internal/streams/readable:568:5)
at readableAddChunk (node:internal/streams/readable:275:5)
at Readable.push (node:internal/streams/readable:234:10)
at node:internal/streams/transform:145:12
at Hash._flush (node:internal/crypto/hash:96:3)
at Hash.final [as _final] (node:internal/streams/transform:132:10)
at callFinal (node:internal/streams/writable:698:12)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
解决方案:
在.npmrc 文件(一般在C盘的user目录下)添加electron相关镜像
ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/
ELECTRON_BUILDER_BINARIES_MIRROR=https://npmmirror.com/mirrors/electron-builder-binaries/