Should you use Node.js for internet improvement, creation of internet apps, and javascript primarily based community purposes, you undoubtedly might come throughout conditions the place you’d wish to make it possible for the newest model of Node.js is put in in your Mac. Upgrading to the newest model of Node.js means you’ll have entry to the newest options and safety updates out there.
Assuming you may have installed Node.js and npm with Homebrew (which means you may have additionally already installed Homebrew on the Mac too), which is arguably the simplest method to set up node.js onto a Mac and to handle the javascript runtime setting, then you’ll discover that updating Node.js to the newest model is de facto fairly easy when you learn the way.
Improve Node.js to the Newest Model on Mac with Homebrew
One of many many advantages of utilizing Homebrew to handle command line software program is that it’s not solely straightforward to put in packages, but in addition to replace them, handle them, and even uninstall them from the Mac. For our functions right here, we’re going to display methods to make it possible for Node.js is up to date to the newest model by utilizing Homebrew. To get began, open the Terminal or your command line app of alternative.
Elective, however not crucial, is to first examine which model of node.js and npm you may have put in on the Mac, which is feasible with the next command:
node -v && npm -v
Now, it would be best to replace Homebrew, in order that Homebrew itself can retrieve the newest variations of software program:brew replace
After brew replace has ran, it would be best to run the brew improve command subsequent. You need to use brew improve for all packages put in with Homebrew, which is beneficial, or you may specify solely upgrading node.js, whichever you like:
Set up updates to all Homebrew packages:brew improve
OPTIONALLY, solely set up and improve to the newest Node.js model through Homebrew:brew improve node
After the improve command has executed, you’ll now need to run the npm replace command, with the set up and -g flag to put in the updates globally to the npm command itself, which appears to be like like this:
npm set up -g npm
After that has accomplished, you may affirm that node.js and npm have been upgraded to the newest variations by working the next command string once more:
node -v && npm -v
And there you may have it, you may have now put in the newest out there variations of Node.js and npm on the Mac, and verified that the newest model is put in, all with the convenience of the Homebrew bundle supervisor.
Technically you can even set up and improve node.js manually with a bundle installer too, however with how handy Homebrew is to handle command line utilities and apps on the Mac, it truly is the only method to go.