Skip to content

Instantly share code, notes, and snippets.

@imshaiknasir
Created June 25, 2025 19:20
Show Gist options
  • Save imshaiknasir/455bab3c61127e7a5f6bb981187a144f to your computer and use it in GitHub Desktop.
Save imshaiknasir/455bab3c61127e7a5f6bb981187a144f to your computer and use it in GitHub Desktop.

guide to install Node.js LTS version 22+

This is the easiest way to get Node.js up and running, and it generally handles the path configuration for you.

  1. Download the LTS Installer:

    • Open your web browser and go to the official Node.js website: https://nodejs.org/en/download/
    • You will see two main download options: "LTS" (Long Term Support) and "Current." Click on the "LTS" button. This will typically download the latest LTS version, which will be Node.js 22+ at the time of this writing.
    • Select the macOS Installer (.pkg).
  2. Run the Installer:

    • Once the .pkg file is downloaded, locate it in your Downloads folder and double-click it to start the installation process.
    • Follow the on-screen prompts. You can generally accept the default installation location, as this usually places Node.js in a standard system path that is already configured.
    • Enter your macOS password when prompted to authorize the installation.
  3. Verify the Installation:

    • Open your Terminal application (you can find it in Applications/Utilities, or by searching with Spotlight).
    • Type the following command and press Enter:
      node -v
    • You should see the installed Node.js version (e.g., v22.x.x).
    • To verify npm (Node Package Manager), which is installed alongside Node.js, type:
      npm -v
    • You should see the installed npm version.

Path Configuration (Usually Automatic with Installer):

The official Node.js installer typically handles adding Node.js to your system's PATH environment variable. This means you usually don't need to manually set it. However, if after verifying the installation, the node -v or npm -v commands don't work (e.g., you get "command not found"), you might need to ensure the path is correctly set.

How to check and potentially add the path (if needed):

Your macOS typically uses zsh as its default shell. The configuration file for zsh is ~/.zshrc.

  1. Check your current PATH:

    • In your Terminal, type:
      echo $PATH
    • Look for /usr/local/bin or a path related to Node.js (e.g., /opt/homebrew/bin if you used Homebrew for other installations). The Node.js installer usually places the executables in /usr/local/bin, which is typically already in your PATH.
  2. Add to PATH (if necessary):

    • If you don't see /usr/local/bin in your PATH or Node.js commands are not found, you can add it manually.
    • Open your ~/.zshrc file in a text editor. You can use nano in the Terminal:
      nano ~/.zshrc
    • Add the following line to the end of the file:
      export PATH="/usr/local/bin:$PATH"
      • Note: If you installed using Homebrew, the path might be /opt/homebrew/bin. If so, use export PATH="/opt/homebrew/bin:$PATH".
    • Press Control + X, then Y to save, and Enter to confirm the filename.
    • Apply the changes: Close your current Terminal window and open a new one, or run:
      source ~/.zshrc
    • Now, try node -v and npm -v again. They should work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment