云效node-gyp 系列 安装特别慢,怎么解决?[阿里云云效]

云效node-gyp 系列 安装特别慢,怎么解决?可能是要从 github 下载的原因
[13:51:22] …/canvas@2.11.2/node_modules/canvas install$ node-pre-gyp install –fallback-to-build –update-binary
[13:51:22] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp info it worked if it ends with ok
[13:51:22] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp info using node-pre-gyp@1.0.11
[13:51:22] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp info using node@18.12.1 | linux | x64
[13:51:22] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.11.2/canvas-v2.11.2-node-v108-linux-glibc-x64.tar.gz
[13:51:24] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp info install unpacking Release/
[13:51:24] …/canvas@2.11.2/node_modules/canvas install: node-pre-gyp info install unpacking Release/libcairo.so.2
部分包下载要十几分钟以上。

「点点赞赏,手留余香」

    还没有人赞赏,快来当第一个赞赏的人吧!
=====这是一个广告位,招租中,联系qq 78315851====
3 条回复 A 作者 M 管理员
  1. 首先,请确认您的网络连接正常,并尝试重新安装。您可以使用nvm uninstall node命令卸载旧版本的Node.js,然后使用nvm install stable命令下载最新版本的Node.js。
    其次,请使用淘宝源来替换官方源,以加快下载速度。您可以在.nvmrc文件中添加下列内容:registry=https://registry.npm.taobao.org。
    再次,请确认您的磁盘空间充足,并清理不必要的文件。您可以通过df -h命令查看磁盘空间使用情况,并使用rm -rf /path/to/file命令删除不必要的文件。

  2. 如果在安装node-gyp系列时速度非常慢,可能是因为它需要从GitHub下载文件。以下是一些可能有助于加快下载速度的建议:

    1. 尝试更改网络环境,例如使用更稳定的Wi-Fi或有线连接。
    2. 更改npm源为国内镜像,这样可以从国内服务器下载文件,可以大大提高下载速度。例如:运行命令 npm config set registry https://registry.npm.taobao.org 或者其他国内镜像源。
    3. 可以考虑使用代理服务器来加速下载过程。
    4. 如果你在公司内网或学校内网中,可能需要与IT部门联系以解决下载问题。
  3. 解决这个问题的方法有很多,以下是一些可能的解决方案:

    1. 使用国内的npm镜像源:国内用户在使用npm或yarn时,可能会遇到下载速度慢的问题。这是因为npm的默认源在国外,因此下载速度较慢。你可以使用国内的npm镜像源,如淘宝的npm镜像源(https://mirrors.aliyun.com/npm/),这样可以大大提高下载速度。

    2. 使用加速工具:有一些工具可以帮助你加速npm或yarn的下载速度,例如npm-speed-up。你可以尝试使用这些工具看看是否能提高下载速度。

    3. 使用代理:如果你的网络环境有限制,你可能需要使用代理来提高下载速度。你可以使用一些免费的代理服务,或者购买付费的代理服务。

    4. 优化网络环境:如果你的网络环境不稳定,也可能会影响下载速度。你可以尝试优化你的网络环境,例如重启路由器,更换网线等。

  4. 您给canvas换个源呢 或者您用云效中国香港构建集群
    比如:.npmrc文件里配置一下: canvas_binary_host_mirror=https://registry.npmmirror.com/-/binary/canvas 此回答整理自钉群“云效交付域答疑群”