Install the latest version of npm and Nodejs on macOS.

Author
By Darío Rivera
Posted On in MacOS

It is common to find that the stable version of macOS does not have updated npm and nodejs packages. Whether you need to update npm or nodejs only, in this post we will show you how to do it.

In this post, we will see how to install npm and Nodejs using nvm. NVM (Node Version Manager) is a version manager for npm with which you can easily install, uninstall and switch between versions without the problems that all this entails.

Installation of NVM

Installing NVM is relatively easy and you can do it in two ways. The first one is to do it via Homebrew with the following command.

brew install nvm

The second way consists of using the official nvm installation script, which is currently in version 0.39.1. To verify the current version, you can visit the NVM repo.

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Installation of Node

After installing nvm, to install the latest version of node, you can execute the following commands.

nvm install node
nvm use node

If you want to install an earlier version such as version 14, you should indicate it as follows.

nvm install 14
nvm use 14

You can verify which versions of node and npm were installed with the following commands.

# node -v
v14.18.2
# npm  -v
6.14.15

Switching Node Versions

To switch Node versions, you must use use.

nvm use 16

If the version to be used is not installed, you must install it first.

nvm install 16
nvm use 16

Acerca de Darío Rivera

Author

Application Architect at Elentra Corp . Quality developer and passionate learner with 10+ years of experience in web technologies. Creator of EasyHttp , an standard way to consume HTTP Clients.

LinkedIn Twitter Instagram

Sólo aquellos que han alcanzado el éxito saben que siempre estuvo a un paso del momento en que pensaron renunciar.