9

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

1
  • 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 (github.com/nvm-sh/nvm#intro) if you're switching Node versions often. Commented Jan 24, 2022 at 16:25

2 Answers 2

22

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


nvm

To do this, you can install nvm.

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


Node.js 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.

Sign up to request clarification or add additional context in comments.

3 Comments

thank you. this is the best method, succinct and headache free.
I did this, but after quitting the terminal, and opening it again, node --version displays another version.
brew install -g [email protected]
2

If you are using Homebrew on your Mac, it is simple as that:

brew install node

If you already have a node version installed, you can upgrade it like this:

brew upgrade node

Then force to link the brew node version:

brew link --overwrite node

These examples install the latest node version. If you prefer a specific version add the version number like node@21 when installing or upgrading.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.