The problem is you have node
installed to two locations, and the one being installed by n
is later in the PATH
variable.
For interest, you can run n doctor
and it should pick up this problem.
The two main options are
- delete the other (homebrew) copy of node, or
- alter
PATH
so /usr/local/bin
is ahead of /opt/homebrew/bin
(but homebrew may want to be first!)
The best option with a homebrew conflict is probably to uninstall the homebrew managed version of node. Assuming you don't have global packages installed other than npm itself:
Short version:
npm uninstall --global npm
brew uninstall node
Long version: the n
documentation recently added this very case in a detailed walkthrough: https://github.com/tj/n/blob/master/docs/changing-node-location.md
(Disclaimer: I am a maintainer of n
.)
hash -r
or open a new shell. Or create a symlink to/usr/local/bin/node
in a directory that has a higher priority in yourPATH
. – Neznvm
it lets you install multiple node versions and use them according to your project requirements. – Kristinkristina