我有一台运行着 macOS 10.13.1
的 Mac。在成功安装了 Homebrew
后,我尝试使用它来安装 Node.js
。
brew install node
安装过程在终端中似乎已经完成了,但是进行版本检查时遇到了问题;
node -v
导致
-bash: node: command not found
有什么指导可以修复这个问题吗?我想避免使用二进制安装node。
我有一台运行着 macOS 10.13.1
的 Mac。在成功安装了 Homebrew
后,我尝试使用它来安装 Node.js
。
brew install node
node -v
-bash: node: command not found
我遇到了这个问题,但是因为我安装的是旧版本的 Node,所以出现了这个问题。对于旧版本而言,路径不会被自动修改,以避免与可能安装的最新版本发生冲突。运行 brew install
命令后,如果你想添加它到你的路径中,它应该会给出相关指示。
尝试运行此命令
brew link node
brew link --overwrite node@16
,这对我起作用了。 - Amir Rezvanibrew doctor
应该会给你一些提示。
我刚刚为我的 Apple M1 进行了全新的安装,似乎没有任何额外的设置就可以正常工作。
$ brew install node
==> Downloading https://ghcr.io/v2/homebrew/core/c-ares/manifests/1.18.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/c-ares/blobs/sha256:7b1eacc9efbe8ac32a4a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7b1e
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/manifests/1.42.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/libuv/blobs/sha256:7b0a2b27ac3b806ff9e59
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:7b0a
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/node/manifests/17.2.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/node/blobs/sha256:f3efe9900c885d5bcc3a39
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:f3ef
######################################################################## 100.0%
==> Installing dependencies for node: c-ares and libuv
==> Installing node dependency: c-ares
==> Pouring c-ares--1.18.1.arm64_monterey.bottle.tar.gz
/opt/homebrew/Cellar/c-ares/1.18.1: 87 files, 665.3KB
==> Installing node dependency: libuv
==> Pouring libuv--1.42.0.arm64_monterey.bottle.tar.gz
/opt/homebrew/Cellar/libuv/1.42.0: 49 files, 3.5MB
==> Installing node
==> Pouring node--17.2.0.arm64_monterey.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
/opt/homebrew/etc/bash_completion.d
==> Summary
/opt/homebrew/Cellar/node/17.2.0: 2,018 files, 44.4MB
==> Running `brew cleanup node`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> node
Bash completion has been installed to:
/opt/homebrew/etc/bash_completion.d
$ ls -al /opt/homebrew/bin/node
lrwxr-xr-x 1 ruichen admin 30 Dec 13 15:56 /opt/homebrew/bin/node -> ../Cellar/node/17.2.0/bin/node
$ node --version
v17.2.0