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.
Cheers,
Renat Galyamov
Want to share this with your friends?
👉renatello.com/upgrade-node-npm-on-mac
PS: Make sure you check other Node.js tutorials, e.g. how to install/uninstall an npm package.