node无法下载sharp模块

在实习中通过npm安装相关依赖时遇到的问题

问题描述

以下问题时在实习中,通过npm安装相关依赖时遇到的问题

1
2
3
4
5
error ..../node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments:
error Command failed with exit code 1.
1
2
3
4
Building fresh packages...

1. [-/5] ⠐ waiting...
2. [-/5] ⠐ waiting...

问题解决

以上问题应该时node中没有下载相应的模块,导致执行报错。查阅资料后得到解决方法。

在项目目录中的配置文件.npmrc文件中添加相关模块的换源

1
2
sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"