-1

I am running into an issue I won't get into that has potential solutions involving upgrading Node. Easy enough right? No, not at all. I have tried running the latest Node installer for Mac. I have tried upgrading with nvm. I have tried upgrading with n. No matter what I do my node -v doesn't change. I have tried all of the top posts' solutions related to this seemingly simple process. It did actually show a newer version number of Node after attempting to upgrade with nvm however after closing and opening the terminal it now shows the node version I began with.

I suspect that I now have multiple installations of Node on my computer which just introduces a host of new problems. However, how the heck do I upgrade Node JS properly once and for all? Nothing seems to be working.

connected_user
  • 814
  • 1
  • 9
  • 25

2 Answers2

1

Updated

Maybe just uninstall node and delete all node-related files. If you have installed node using homebrew then it is pretty straightforward, just run these commands:

brew uninstall --ignore-dependencies node 
brew uninstall --force node 

Then update and install nvm

brew update
brew install nvm 

Next, create a directory for NVM in home.

mkdir ~/.nvm 

Now, configure the required environment variables. Edit the following configuration file in your home directory

vim ~/.bash_profile 

and, add below lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later).

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

Press ESC + :wq to save and close your file.

Next, load the variable to the current shell environment. From the next login, it will automatically loaded.

source ~/.bash_profile

Old

Install your desired node version using the command

nvm install <version>

Then you can see all the installed versions using the command:

nvm list

Then use can switch to specific version using command:

nvm use <version>

Another method is to uninstall and delete all the node related files and install using Homebrew, but I recommend and use nvm

brew install node@<version>
iftikharyk
  • 870
  • 5
  • 10
0

Try this:

sudo chown -R $(whoami):admin /usr/local/*

then:

rm -rf /usr/local/include/node
brew unlink node
brew link node 

if doesn't work de link you can use this:

brew link --overwrite node

Anyway, after first command you can update brew or uninstall and install again node and do the link if it's necessary without problem...

Anthony Piñero
  • 616
  • 5
  • 10