nvm command not found - macOS

How to Install nvm Command on macOS

If you are using macOS and trying to use the nvm command but encountering a “command not found” error, it means that Node Version Manager (nvm) is not installed on your system. NVM is a tool that allows you to easily switch between different versions of Node.js on your machine.

To install nvm on macOS and start using it, follow the steps below:

  1. Open a terminal window on your macOS system.

  2. Install Homebrew if you don’t have it already. Homebrew is a package manager for macOS that makes it easy to install software packages. You can install Homebrew by running the following command in your terminal:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    
  3. Once Homebrew is installed, use it to install nvm by running the following command:

    brew install nvm
    
  4. After the installation is complete, you may need to add the following line to your shell configuration file (such as ~/.bash_profile, ~/.zshrc, or ~/.bashrc) to ensure that nvm is loaded when you open a new terminal window:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    
  5. Close and reopen your terminal window or run source ~/.bash_profile (or the corresponding file for your shell) to apply the changes.

  6. You can now use the nvm command to manage different versions of Node.js on your macOS system.

If any of the above commands are not compatible with your macOS system, please check the official documentation for nvm at https://github.com/nvm-sh/nvm for alternative installation methods specific to macOS.

Conclusion

By following the steps outlined above, you should now have successfully installed the nvm command on your macOS system. You can now leverage nvm to manage and switch between different versions of Node.js seamlessly. Enjoy coding with Node.js using nvm on your macOS machine!