How to install Node.js on macOS



Image not found!!

To install Node.js on macOS, you can use either the Node Version Manager (NVM) or the official Node.js installer. Here are instructions for both methods:

Using Node Version Manager (NVM):

  1. Install NVM: Open your terminal and run the following command to install NVM:

    bash
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  2. Close and Reopen Terminal: Close and reopen your terminal or run the following command to apply the changes without restarting:

    bash
    source ~/.bashrc
  3. Install Node.js: After installing NVM, you can install the latest version of Node.js with the following command:

    bash
    nvm install node
  4. Use the Installed Version: Once the installation is complete, you can use the installed Node.js version by default. If you need to switch between versions, you can use nvm use <version>.

Using the Official Node.js Installer:

  1. Download the Installer: Visit the official Node.js website at https://nodejs.org/, and click on the "LTS" (Long-Term Support) version. This version is recommended for most users.

  2. Run the Installer: Open the downloaded file (usually a .pkg file), and follow the installation prompts.

  3. Verify Installation: After the installation is complete, open a terminal and run the following commands to verify that Node.js and npm (Node Package Manager) are installed:

    bash
    node -v
    npm -v

    This should display the installed versions of Node.js and npm.

That's it! You have successfully installed Node.js on your macOS system. Choose the method that suits your preferences or requirements.