I already had Node.js installed on my computer, but for some reason, I was having some difficulty updating it directly from the Node.js website. So instead, I decided to use Homebrew to update it. Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. #BlackLivesMatter New security releases now available for 15.x, 14.x, 12.x and 10.x release lines.
By Panu Pitkamaki
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 download the installer from nodejs.org. However, you might not want to be downloading a 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
Nvm is 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.
The last option installs all global npm packages over to your new version. This way packages like mocha and node-inspector keep working.
N
N is an npm-based node version manager. You can install it by installing first some version of node and then running
npm install -g n
.Homebrew Node Js M1
Assuming you have successfully installed n. The following will install the latest version of node.
![Brew node 12 Brew node 12](/uploads/1/1/8/6/118662278/472751905.png)
Homebrew
Homebrew is one of the two popular package managers for Mac. Assuming you have previously installed node with
brew install node
. You can get up-to-date with formulae and upgrade to the latest Node.js version with the following.MacPorts
MacPorts is the other 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 a previous version of the package installed.
There also exists
nodejs
alternative to nodejs-devel
that follows the long term support line.If you’re looking for an easy guide to install Node.js and npm on OS X and macOS — this is it.
Before we get started, are you listening to JS Party? If not, you should be! Maybe start with our episode all about best practices for Node developers. ✊
The default method for installing Node.js is to download a pre-built installer for your platform, install it and make sure it’s on your
$PATH
.However, if you’re a Homebrew fan like me and prefer to install all of your packages with it — ensuring your packages are installed using the same commands and directories and allowing Homebrew to easily manage upgrades and updates — then this guide will help you get started.
Install Node.js and npm with Homebrew
First, install Homebrew.
Then run
brew update
to make sure Homebrew is up to date.As a safe measure you should run
brew doctor
to make sure your system is ready to brew. Run the command below and follow any recommendations from brew doctor.Next, add Homebrew’s location to your
$PATH
in your .bash_profile
or .zshrc
file.Next, install Node (npm will be installed with Node):
To test out your Node and npm install, try installing Grunt (you might be asked to run with sudo):
If that worked then congratulations — you’ve installed Node.js, npm, and Grunt.
If not — retrace your steps or post a question to Stack Overflow.
Listen to related podcasts on The Changelog
![Homebrew install nodejs Homebrew install nodejs](https://mianliencoding.com/UpImages/Install_NodeJs_ 3.png)
Brew Install Node Lts
Since you’re interested in Node.js, npm, and Homebrew — listen to some recent related podcasts we’ve done on those subjects.