In this tutorial, you’ll learn how to upgrade Node.js and NPM on a Mac.
First of all, open a Terminal app and check app versions.
$ node -v && npm -v
The command below will print current versions of the apps. If you haven’t updated Node.js and NPM in a while they’re most likely out of date.
How to upgrade NPM
Now let’s upgrade NPM to the latest version.
$ sudo npm install -g npm
How to upgrade Node.js using Homebrew
If you installed Node.js using Homebrew, you can upgrade it using the command below.
$ brew update && brew upgrade node
How to upgrade Node.js using n
Alternatively, you can install it using n package. It’s a Node.js manager. But of all, you need to clean npm cache.
$ sudo npm cache clean -f
Install N package, right after cleaning the cache.
$ sudo npm install -g n
Install Node.js stable. Finally, let’s install and update Node.js.
$ sudo n stable
If you find this post useful, please let me know in the comments below and subscribe to my newsletter.
Want to share this with your friends?