Tag Archives: 4 ways to update to the latest Node.js version on a Mac

4 ways to update to the latest Node.js version on a Mac

Development is picking pace and Node.js is shipping out a new version frequently. It is nice to have the latest version at hand in your development environment to test out new features.

There are a few ways to install Node.js. One of the obvious ones is to simply download the installer fromnodejs.org. However, you might not want to be downloading new installer every time there’s a new version out.

Here are few alternative ways to update to the latest version of Node.js on a Mac.

Nvm

Nvmis a script-based node version manager. You can install it easily with a curl and bash one-liner as described in the documentation. It’s also available on Homebrew.

Assuming you have successfully installed nvm. The following will install the latest version of node.

1 nvm install node --reinstall-packages-from=node

The last option installs all global npm packages over to your new version. This way packages likemochaandnode-inspectorkeep working.

N

Nis an npm-based node version manager. You can install it by installing first some version of node and then runningnpm install -g n.

Assuming you have successfully installed n. The following will install the latest version of node.

1 sudo n latest

Homebrew

Homebrewis one of the two popular package managers for Mac. Assuming you have previously installed node withbrew install node. You can get up-to-date with formulae and upgrade to the latest Node.js version with the following.

1 brew update
2 brew upgrade node

MacPorts

MacPortsis the another package manager for Mac. The following will update the local ports tree to get access to updated versions. Then it will install the latest version of Node.js. This works even if you have previous version of the package installed.

1 sudo port selfupdate
2 sudo port install nodejs-devel

There exists alsonodejsalternativepackagethat follows the long term support line.