There are several ways to upgrade the node.js version. Easiest way is to through NPM package.
Open the terminal in macOS and run the following command.
To check the current version of the node.js
$ node -v v10.15.3
Clean the npm cache:
$ sudo npm cache clean -f
Install the n node version management package:
$ sudo npm install -g n /usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n + email@example.com added 1 package from 2 contributors in 1.433s
Upgrade to the current stable version
$ sudo n stable installing : node-v14.17.0 mkdir : /usr/local/n/versions/node/14.17.0 fetch : https://nodejs.org/dist/v14.17.0/node-v14.17.0-darwin-x64.tar.xz installed : v14.17.0 (with npm 6.14.13)
Verify the version of the node.js
$ node -v v14.17.0
Node.js upgraded successfully to the latest version v14.17.0.
sudo is optional command. Don’t use it unless you don’t have permission to upgrade.
Happy Blogging 😃