【问题标题】:Homebrew install Node.js : Command Not Found自制安装 Node.js:找不到命令
【发布时间】:2018-10-25 19:00:43
【问题描述】:

我有一台运行 macOS 10.13.1 的 Mac。成功安装Homebrew后,我尝试用

安装Node.js
brew install node

在终端中安装似乎完成得很好,但是要进行版本检查;

node -v

结果

-bash: node: command not found

关于如何解决这个问题的任何指示?,我试图避免必须从二进制安装节点。

【问题讨论】:

标签: node.js macos terminal homebrew


【解决方案1】:

我遇到了这个问题,但这是因为我正在安装旧版本的节点。对于旧版本,不会自动修改路径以避免与可能安装的最新版本冲突。运行brew install 命令后,它应该会告诉你如何将它添加到你的路径中,如果你想这样做的话。

【讨论】:

    【解决方案2】:

    尝试运行此命令

    brew link node
    

    【讨论】:

    • 一个好的答案将始终包括解释为什么这会解决问题,以便 OP 和任何未来的读者可以从中学习。
    【解决方案3】:

    brew 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-26
      • 1970-01-01
      • 1970-01-01
      • 2013-03-28
      • 2016-11-04
      • 2022-01-12
      • 2018-06-17
      • 2014-01-13
      相关资源
      最近更新 更多