You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行npm install安装依赖时sharp包请求超时报错求助

解决npm安装sharp时libvips下载超时问题

npm ERR! code 1
npm ERR! path C:\Users\HP\Desktop\workings\alx-files_manager\node_modules\sharp
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-win32-x64.tar.br
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: Request timed out
npm ERR! A complete log of this run can be found in: C:\Users\HP\AppData\Local\npm-cache_logs\2024-03-12T17_05_23_036Z-debug-0.log

以下是可行的解决方法:

  • 清理npm缓存后重试
    先清理缓存,再重新执行安装命令:

    npm cache clean --force
    npm install
    
  • 使用国内镜像源加速下载
    临时切换npm镜像为国内源,再执行安装:

    npm config set registry https://registry.npmmirror.com/
    npm config set sharp_binary_host https://npmmirror.com/mirrors/sharp
    npm config set sharp_libvips_binary_host https://npmmirror.com/mirrors/sharp-libvips
    npm install
    

    安装完成后如需恢复原镜像,执行:

    npm config delete registry
    npm config delete sharp_binary_host
    npm config delete sharp_libvips_binary_host
    
  • 手动下载libvips并指定路径

    1. 手动下载报错中提到的v8.12.2-win32-x64版本libvips压缩包
    2. 解压到本地任意路径,比如C:\libvips
    3. 设置环境变量后执行安装:
    set SHARP_LIBVIPS_DIRECTORY=C:\libvips
    npm install
    
  • 检查网络环境

    • 关闭正在运行的代理工具
    • 切换到稳定的有线网络或更换网络环境后重试安装

内容的提问来源于stack exchange,提问作者Time flies

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 04:10:05