Improve doc for Mac OS (Ventura) with homebrew
elmar-hinz opened this issue · comments
Summary
In the PATH /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin: ...
/opt/homebrew/bin
comes before /usr/local/bin
. As long as there are node
, npm
or npx
in the homebrew part, n
will not work as expected.
Details
If the user should not fiddle with the path, homebrew has to give up control of node. That in turn means brew install n
is a good way to get n
installed.
There are other issues. A mere brew uninstall node
is not enough. It does not remove npm
and npx
.
Solution
This did work for me:
# removing bin/npm and bin/npx
npm uninstall -g npm
# removing bin/node
brew uninstall node
# installing n
brew install n
# installing node
sudo n install latest
# some checks
which node
which npm
which npx
There can be problems in general with multiple installs of node to different locations. This comes up with Homebrew on Apple Silicon Macs, but not with Intel Macs.
https://docs.brew.sh/Installation
This script installs Homebrew to its default, supported, best prefix (
/usr/local
for macOS Intel,/opt/homebrew
for Apple Silicon and/home/linuxbrew/.linuxbrew
for Linux) ...
Changing the install location takes extra work if you already have some global npm packages installed (like npm itself!), as they will also need uninstalling from the old location and installing in the new location.
In a general sense, the problem here is multiple installs of node/npm/npx. n
does warn about a shadowed version of node but not of a shadowed version of npm.
Would it help if n
warned about npm being shadowed? (Previously suggested in: #762)
Or are people liking this issue more interested in specific help about transitioning in Homebrew?
(I wonder if the n
formula could offer suggestions, but not sure if that is appropriate for formula. I am a light user of Homebrew and do see some tips when installing products.)
Something I have been thinking about is transferring global packages. That just came up in #800.