3

I am using macOS Big Sur and want to update my Node. However, after downloading its file from the official website and completing its installation, my terminal still shows and uses my previous node version.

Does anyone know how can I overcome this issue?

Thanks

terminal screenshot

Sina Rahimi
  • 221
  • 1
  • 3
  • 10
  • Make sure you uninstall node before installing the new version. Also, make sure you restart your terminal after installing node. Additionally, you make want to look into using Node Version Manager (https://github.com/nvm-sh/nvm#intro) if you're switching Node versions often. – Matt Davis Jan 24 '22 at 16:25

2 Answers2

12

I suggest using nvm. It's much simpler and eradicates the headache of updating.

nvm

To do this, you can install nvm. https://github.com/nvm-sh/nvm#installing-and-updating

you will be pasting in the curl command curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Note: when this is finished running, you should see a line near the bottom which says something like export NVM_DIR="$HOME/.nvm"

Copy and paste this and hit enter.

Then check to make sure you have nvm installed now nvm -v

Nodejs update

After, in the terminal, type: nvm install node (you can also check your current version first with node -v

Run it and then check node version again. It should be updated.

npm

While you're at it, you can also update npm.

Check version npm -v Update npm install -g npm

This should do it. Let me know if there are any issues. Note: this can all be done in the -zsh shell, no reason to move back to bash.

FreddyNoNose
  • 320
  • 1
  • 14
-1

The error displayed was sudo: n: command not found, which hinted that the binary might have not been successfully installed on your system. You need to check the location of n executable by using which command:

$ which n

Reinstalling n with more verbose debug level may also provide you with better information for troubleshooting.

$ sudo npm install --loglevel verbose -g n

Among possible options to install Node.js on MacOS, n was tested to be less error prone as you can read here. You should be on the right direction with the package manager choice.

mikaelfs
  • 399
  • 3
  • 4