Using Node Version Manager (NVM) on macOS/Linux

  • Install NVM by running the command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
  • Restart your terminal or run:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  • Verify the installation by typing:
nvm --version
  • Install the latest Node.js version:
nvm install node
  • Use the installed version:
nvm use node
  • Verify the Node.js version:
node -v

Using Node.js Installer (Windows/macOS)

  • Run the installer and follow the on-screen instructions.
  • After installation, verify the Node.js version:
node -v

Using n Package on Linux/macOS

  • Install n globally:
npm install -g n
  • Upgrade to the latest version of Node.js:
sudo n latest
  • Verify the Node.js version:
node -v

Using Homebrew on macOS

  • Update Homebrew:
brew update
  • Upgrade Node.js:
brew upgrade node
  • Verify the Node.js version:
node -v

Using Chocolatey on Windows

  • Open Command Prompt as Administrator.
  • Upgrade Node.js using Chocolatey:
choco upgrade nodejs
  • Verify the Node.js version:
node -v

Additional Steps

  • Update npm to the latest version:
npm install -g npm@latest
  • Verify npm version:
npm -v

These methods ensure you have the latest Node.js version installed.

Leave a Reply