最慢的是下载这个文件:https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-darwin-x64.tar.gz,
只要涉及到github上文件下载,可能都会巨慢:
参考官方文档,可以先把文件下载下来,再挂到我们自己的服务上,安装前设置环境变量,走我们自己的服务下载文件:
sharp - High performance Node.js image processing
下载问题本质还是访问github太慢导致的,也可以尝试想办法,提高访问速度。
文件下载问题解决了,安装还是报错的话,也可能是node版本问题!
这里报错,很可能是sharp还不支持node 13 等高版本,降低node版本之后恢复正常。
之前下载node-sass也是死活下载不下来:
先手动下载node文件,
Downloading binary from
https://github.com/sass/node-sass/releases/download/v4.6.0/win32-x64-57_binding.node
再设置环境变量:
set SASS_BINARY_PATH=D:/WorkCode/win32-x64-46_binding.node
这个可以直接设置为本地的绝对路径,再尝试重新安装。
2021-3-30
sharp中国镜像来了:
sharp - High performance Node.js image processing
依次执行命令:
npm config set sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
npm config set sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"
npm install sharp
自从用了yarn,node-sass没再出现幺蛾子。
2022-07-25
也可以尝试cnpm,最近又搞uni项目,切到了sass上。