当前位置: 首页 > news >正文

解决 npm i sharp@0.23.4 安装失败异常 npm install sharp异常解决

解决 npm i sharp@0.23.4 安装失败异常 npm install sharp异常解决

  • 解决 npm i sharp@0.23.4 安装失败异常 npm install sharp异常解决

解决 npm i sharp@0.23.4 安装失败异常 npm install sharp异常解决

本地环境:node: 12.20.1

异常提示关键字:Python、C++编译问题
在这里插入图片描述

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.8.1/libvips-8.8.1-win32-x64.tar.gz
ERR! sharp Prebuilt libvips binaries are not yet available for win32-x64
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependenciesD:\java-works\yzwl\temp\node_modules\sharp>if not defined npm_config_node_gyp (node "D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version was set from command line or npm config
gyp ERR! find VS - looking for Visual Studio version 2022
gyp ERR! find VS running in VS Command Prompt, installation path is:
gyp ERR! find VS "D:\apps\Microsoft\VisualStudio"
gyp ERR! find VS - will only use this version
gyp ERR! find VS unknown version "undefined" found at "D:\apps\Microsoft\VisualStudio"
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - found in "D:\Program Files (x86)\Microsoft Visual Studio 14.0"
gyp ERR! find VS - could not find MSBuild in registry for this version
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS msvs_version does not match this VS Command Prompt or the
gyp ERR! find VS installation cannot be used.
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the "Desktop development with C++" workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack     at VisualStudioFinder.fail (D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack     at D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack     at D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack     at D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:384:20
gyp ERR! stack     at D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack     at D:\apps\nvm\v12.20.1\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:315:5)
gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1022:16)
gyp ERR! System Windows_NT 10.0.22631
gyp ERR! command "D:\\apps\\nvm\\nodejs\\node.exe" "D:\\apps\\nvm\\v12.20.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\java-works\yzwl\temp\node_modules\sharp
gyp ERR! node -v v12.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm WARN temp@1.0.0 No description
npm WARN temp@1.0.0 No repository field.npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.23.4 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sharp@0.23.4 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

这个异常就是因为 sharp依赖于_libvips编译模块,需要调用编译模块之后才能安装sharp,但是npm下载和编译失败了,需要手动将预编译的二进制文件下载下来放到本地npm缓存路径当中

Sharp版本0.23.4对应的libvips下载地址: libvips-8.8.1-win32-x64.tar.gz

默认的NPM缓存路径:C:\Users\用户\AppData\Roaming\npm-cache\_libvips

npm-cache\_libvips 是用于存放预编译的二进制文件缓存路径

在这里插入图片描述

通过CMD查询具体本机的NPM缓存路径:

# 查看当前 npm 缓存路径
npm config get cache

在这里插入图片描述

最后执行安装sharp查看是否成功

npm i sharp@0.23.4
http://www.lryc.cn/news/612760.html

相关文章:

  • dmctlcvt工具介绍数据文件路径变化后如何拉起数据库
  • 范数的定义、分类与 MATLAB 应用实践
  • agno fastapi对外接口案例
  • 北京JAVA基础面试30天打卡04
  • Node.js特训专栏-实战进阶:21.Nginx反向代理配置
  • 使用Spring Boot + Angular构建安全的登录注册系统
  • 剧本杀小程序系统开发:推动社交娱乐产业创新发展
  • GitCode 7月:小程序积分商城更名成长中心、「探索智能仓颉!Cangjie Magic 体验有奖征文活动」圆满收官、深度对话栏目持续热播
  • qt系统--事件
  • OpenAI推出开源GPT-oss-120b与GPT-oss-20b突破性大模型,支持商用与灵活部署!
  • Numpy科学计算与数据分析:Numpy数组操作入门:合并、分割与重塑
  • 水库大坝安全监测系统主要概述
  • Python 数据类型及数据类型转换
  • Python Socket 脚本深度解析与开发指南
  • 目标检测数据集 - 自动驾驶场景道路异常检测数据集下载「包含VOC、COCO、YOLO三种格式」
  • Jenkins全链路教程——Jenkins用户权限矩阵配置
  • 东莞立晟精密硅胶科技有限公司将携重磅产品亮相 AUTO TECH China 2025 广州国际汽车技术展
  • oracle 11G安装大概率遇到问题
  • 计算机网络:固定网络位长度子网划分flsm和可变长子网掩码划分vlsm的区别
  • QT项目 -仿QQ音乐的音乐播放器(第五节)
  • 全局异常处理器
  • [特殊字符] 未来图钉式 AI 时代的智能生态布局:副脑矩阵与人机共振的系统构想
  • Linux->信号
  • 如何在 VS Code 中进行 `cherry-pick`
  • 计算机毕业设计java疫情防控形势下的高校食堂订餐管理系统 高校食堂订餐管理系统在疫情防控背景下的设计与实现 疫情防控期间高校食堂线上订餐管理平台
  • 【已解决】-bash: mvn: command not found
  • 2025数字马力一面面经(社)
  • [优选算法专题一双指针——两数之和](双指针和哈希表)
  • git branch -a无法查看最新的分支
  • 垃圾桶满溢识别准确率↑32%:陌讯多模态融合算法实战解析