7

I have a Mac running macOS 10.13.1. After installing Homebrew successfully, I tried to intall Node.js with

brew install node

The installation seems to complete fine in the terminal, however following up with a version check ;

node -v

results in

-bash: node: command not found

Any pointers on how to fix this ?, I am trying to avoid to have to install node from binary.

fitzmode
  • 1,007
  • 1
  • 18
  • 29
  • dupe: https://stackoverflow.com/questions/33575082/brew-install-npm-npm-command-not-found – Max Baldwin May 15 '18 at 20:36
  • 2
    I'd say avoid using brew or apt-get type tools for node, and just use either N or NVM, https://github.com/creationix/nvm , you can use multiple versions of node and they are super easy to switch too! – ishaan May 15 '18 at 20:36
  • Sounds like it could be a path problem. What do you get when you type 'which node' – Natsfan May 15 '18 at 21:34

3 Answers3

5

try running this command

brew link node
4

I was having this issue but it was because I was installing an older version of node. For older versions, the path isn't modified automatically to avoid colliding with the potentially installed up to date version. After running the brew install command, it should give you instructions on how to add it to your path if thats what you want to do.

pricheal
  • 86
  • 3
0

brew doctor should give you some hints.

I just did a fresh installation for my Apple M1, seems just working fine without any additional setup.

$ 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
chenrui
  • 8,910
  • 3
  • 33
  • 43