当前位置:网站首页>npm无法安装sharp
npm无法安装sharp
2022-07-06 15:10:00 【用户6256742】
sharp包是基于node.js的高性能图片处理器
但是在使用npm/yarn对sharp安装时经常会出现安装失败的问题,主要原因是安装源的问题所以我们可以选择为包管理器换源或者手动下载并安装。
换源
三个命令只执行一个即可
- 使用镜像地址(仅设置sharp):
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源都修改为cnpm
npm config set registry https://registry.npmmirror.com- yarn修改方式
yarn config set registry https://registry.npmmirror.com手动下载
- 提前下载好sharp某版本号对应的libvips依赖包,放在npm的缓存路径中,通常这个路径是
/Users/<username>/.npm/_libvips(在使用了nvm管理node版本的情况下,正常情况下执行1操作后就没有问题了)
如果没有提前下载好并放在缓存中,可能会出现如下的报错信息
info sharp Using cached /Users/<usernmae>/.npm/_libvips/libvips-8.10.0-darwin-x64.tar.br
ERR! sharp Decompression failed
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/install for required dependencies
TOUCH Release/obj.target/libvips-cpp.stamp
CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
LIBTOOL-STATIC Release/nothing.a
CXX(target) Release/obj.target/sharp/src/common.o
../src/common.cc:24:10: fatal error: 'vips/vips8' file not found
#include <vips/vips8>
^~~~~~~~~~~~
1 error generated.
make: *** [Release/obj.target/sharp/src/common.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/maxingyuan/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:311:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/Users/<usernmae>/.nvm/versions/node/v12.16.1/bin/node" "/Users/<usernmae>/.nvm/versions/node/v12.16.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/maxingyuan/.nvm/versions/node/v12.16.1/lib/node_modules/sharp
gyp ERR! node -v v12.16.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] 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 [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/<usernmae>/.npm/_logs/2020-11-11T07_51_13_893Z-debug.log具体换源可以参考文章:npm、yarn切换淘宝源
边栏推荐
- ResNet-RS:谷歌领衔调优ResNet,性能全面超越EfficientNet系列 | 2021 arxiv
- 云原生技术--- 容器知识点
- Daily question 1: force deduction: 225: realize stack with queue
- Self made j-flash burning tool -- QT calls jlinkarm DLL mode
- 关于声子和热输运计算中BORN电荷和non-analytic修正的问题
- 基於 QEMUv8 搭建 OP-TEE 開發環境
- General implementation and encapsulation of go diversified timing tasks
- 【雅思口语】安娜口语学习记录part1
- 手写ABA遇到的坑
- 软考高级(信息系统项目管理师)高频考点:项目质量管理
猜你喜欢

每日一题:力扣:225:用队列实现栈

UE4蓝图学习篇(四)--流程控制ForLoop和WhileLoop

Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题

树的先序中序后序遍历

第3章:类的加载过程(类的生命周期)详解

2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9

Web APIs DOM 时间对象

Pit encountered by handwritten ABA

硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件

重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
随机推荐
Chapter 4: talk about class loader again
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
2022-07-05 stonedb sub query processing parsing time analysis
Seata聚合 AT、TCC、SAGA 、 XA事务模式打造一站式的分布式事务解决方案
Chapter 3: detailed explanation of class loading process (class life cycle)
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
Senior soft test (Information System Project Manager) high frequency test site: project quality management
RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv
每日一题:力扣:225:用队列实现栈
基於 QEMUv8 搭建 OP-TEE 開發環境
Memorabilia of domestic database in June 2022 - ink Sky Wheel
二分图判定
pytorch_YOLOX剪枝【附代码】
LeetCode 练习——剑指 Offer 26. 树的子结构
const关键字
Leetcode: interview question 17.24 Maximum cumulative sum of submatrix (to be studied)
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
Aardio - 通过变量名将变量值整合到一串文本中
uniapp滑动到一定的高度后固定某个元素到顶部效果demo(整理)
关于声子和热输运计算中BORN电荷和non-analytic修正的问题