执行yarn install报错‘Internal Error: Error when performing the request’求助
解决yarn/npm安装依赖时的请求错误问题
问题详情
执行yarn install时触发以下错误:
Internal Error: Error when performing the request at ClientRequest.<anonymous> (C:\Program Files\nodejs\node_modules\corepack\dist\corepack.js:16073:20) at ClientRequest.emit (node:events:512:28) at TLSSocket.socketErrorListener (node:_http_client:496:9) at TLSSocket.emit (node:events:512:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
注:npm install在其他项目可正常运行,未使用代理。
解决方案
- 清除包管理器缓存
- 清理npm缓存:
npm cache clean --force - 清理Corepack管理的yarn缓存:
corepack yarn cache clean
- 清理npm缓存:
- 切换国内包源(规避网络请求超时)
- 设置npm源:
npm config set registry https://registry.npmmirror.com/ - 设置yarn源:
corepack yarn config set registry https://registry.npmmirror.com/
- 设置npm源:
- 重置项目依赖文件
- 删除项目根目录下的
package-lock.json、yarn.lock和node_modules文件夹 - 重新执行
npm install或yarn install
- 删除项目根目录下的
- 修复Corepack环境
- 重新启用Corepack:
corepack enable - 重新安装Corepack:
npm install -g corepack
- 重新启用Corepack:
- 验证网络连通性
- 在PowerShell中测试源地址可达性:
Invoke-WebRequest https://registry.npmmirror.com/ - 排查防火墙/安全软件是否拦截包管理器的网络请求
- 在PowerShell中测试源地址可达性:
内容的提问来源于stack exchange,提问作者Nathaniel M.
相关产品推荐
相关产品推荐

