目录

Homebrew-Mac安装Node报错

概述

Mac 的环境千差万别,还有国内各种网络不通的问题,需要通过各种代理到各种源,所以处理这种问题经常会很麻烦,但是通过仔细阅读输出的错误日志,问题还是可以定位得到的。

问题和解决

下面是通过 brew install node 执行,但是报错了。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# brew install node
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/libuv-1.42.0.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404

Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/manifests/1.42.0
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/4ce1023eed1fe46fcf9d27bb80ca32edb847285d1976eb5663e78eebf13c5982--libuv-1.42.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/blobs/sha256:9065ec0fbc415fa235ed422edb22fd45b28d5a3207ce9e1b0565903f2ce33fd4
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/3bf90de0784d8836130616c725afabfcea9c770bd877c65c44dad32a09d9a8ae--libuv--1.42.0.monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1m.monterey.bottle.tar.gz
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/aeaeddbc066154a6a2c95c81e016b45e24802199c03562d19cd5ea2f4563651a--openssl@1.1-1.1.1m.monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/node-17.3.0.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404

Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/node/manifests/17.3.0
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/62db815e59375a25f6a69241c76599c42de672de4feac8071b4131cbc60bc444--node-17.3.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/node/blobs/sha256:d2ca921aa8849d4492d5de83bcd47b3db062a17e73b25d9cc4fe6649f59b51cb
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/963a04111f17107835e51b203e1a65049873201b2455c19576985353ef6dda37--node--17.3.0.monterey.bottle.tar.gz
==> Installing dependencies for node: libuv and openssl@1.1
==> Installing node dependency: libuv
==> Pouring libuv-1.42.0.monterey.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /Users/runzhliu/Library/Caches/Homebrew/downloads/e874c93159bf4856f79b7934a9a25556c21423f7241632362bb9a62160b6b476--libuv-1.42.0.monterey.bottle.tar.gz

很多同学这里就会卡住,所以还是要仔细看看报错的日志,这里说 libuv 找不到,那换个思路,先 brew install libuv,发现成功了。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# brew install libuv
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/libuv-1.42.0.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404

Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/manifests/1.42.0
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/4ce1023eed1fe46fcf9d27bb80ca32edb847285d1976eb5663e78eebf13c5982--libuv-1.42.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/blobs/sha256:9065ec0fbc415fa235ed422edb22fd45b28d5a3207ce9e1b0565903f2ce33fd4
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/3bf90de0784d8836130616c725afabfcea9c770bd877c65c44dad32a09d9a8ae--libuv--1.42.0.monterey.bottle.tar.gz
==> Pouring libuv--1.42.0.monterey.bottle.tar.gz

虽然没仔细看过 brew 的代码,但是根据这两处日志,判断我采用的 brew 的源中没有 libuv–1.42.0.monterey.bottle.tar.gz 这个包,但是有 node 的包,而在下载的过程中,一般来说遇到 domain,也就是源不存在的包,可能会降级到默认的 domain,可能是国外的源,但是这里安装 node 的时候已经选定了我设置的源,所以找 libuv 的时候没找到,但是没有直接给降级到默认的 domain,所以这里存在我直接 brew install libuv 成功,但是通过 brew install node 来安装 libuv 失败了。

最后 libuv 安装成功后,重新执行一下 brew install node 问题就解决了。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
➜  /tmp brew install node
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/openssl%401.1-1.1.1m.monterey.bottle.tar.gz
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/aeaeddbc066154a6a2c95c81e016b45e24802199c03562d19cd5ea2f4563651a--openssl@1.1-1.1.1m.monterey.bottle.tar.gz
==> Downloading https://mirrors.ustc.edu.cn/homebrew-bottles/bottles/node-17.3.0.monterey.bottle.tar.gz
curl: (22) The requested URL returned error: 404

Warning: Bottle missing, falling back to the default domain...
==> Downloading https://ghcr.io/v2/homebrew/core/node/manifests/17.3.0
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/62db815e59375a25f6a69241c76599c42de672de4feac8071b4131cbc60bc444--node-17.3.0.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/node/blobs/sha256:d2ca921aa8849d4492d5de83bcd47b3db062a17e73b25d9cc4fe6649f59b51cb
Already downloaded: /Users/runzhliu/Library/Caches/Homebrew/downloads/963a04111f17107835e51b203e1a65049873201b2455c19576985353ef6dda37--node--17.3.0.monterey.bottle.tar.gz
==> Installing dependencies for node: openssl@1.1
==> Installing node dependency: openssl@1.1
==> Pouring openssl@1.1-1.1.1m.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/openssl@1.1/1.1.1m: 8,081 files, 18.5MB
==> Installing node
==> Pouring node--17.3.0.monterey.bottle.tar.gz
🍺  /usr/local/Cellar/node/17.3.0: 1,976 files, 45.8MB
==> Running `brew cleanup node`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
警告
本文最后更新于 2017年2月1日,文中内容可能已过时,请谨慎参考。