MacOS upgrades Node.js to latest version

Upgrade Node.js to the latest version on Mac OS

Upgrade Node.js to the latest version on Mac OS

1. brew


If you initially installed Node.js with Homebrew , run:
If you originally installed Node.js using Homebrew, run:

brew update
brew upgrade node
npm install -g npm

Or as a one-liner:
Or as a one-liner:

brew update && brew upgrade node && npm install -g npm

2. n

A convenient way to change versions is to use n:
Use n:

brew install n

To install the latest version of Node.js with n:
To install the latest version of Node.js with n:

n latest

Or, to install the latest LTS version with n:

n lts

3. nvm

Alternatively, you could use nvm instead of n:
n:

brew install nvm

To install the latest version of Node.js with nvm:
To install the latest version of Node.js with nvm:

nvm install node

4. package

If you installed via a package, then download the latest version from nodejs.org. See Installing Node.js and updating npm.
If you are installing via package, download the latest version from nodejs.org. See Installing Node.js and updating npm.

Run npm install -g node after following above instructions if your node version is still not updated.
If your node version is still not updated, please run npm install - gnode.

Guess you like

Origin blog.csdn.net/sexyluna/article/details/134102706