This blog post will provide you with a step-by-step guide on how to install Node Version Manager (NVM) on your Mac. NVM is a command-line utility that allows you to manage and switch between different versions of Node.js and npm.
Prerequisites
You would need to have a Mac running on an operating system that supports NVM. Most MacOS versions are compatible with NVM.
Step 1: Open Terminal
Begin by opening Terminal on your Mac. You can find it in your Applications folder, under Utilities, or you can simply search for it using Spotlight.
Step 2: Download and Install NVM
Copy the install script from the NVM GitHub repository and run it in your terminal. Here is the command to do it:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
This command will download the script and run it. The script clones the NVM repository to ~/.nvm and adds the source line to your profile ( ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
Step 3: Verify Installation
Once the installation is complete, you can confirm the installation of NVM by running:
command -v nvm
This should output ‘nvm’, indicating that NVM is installed and working.
Step 4: Install Node.js
Now that you have NVM installed, you can install Node.js. To install the latest version of Node.js, you can run the following command:
nvm install node
This will download and install the latest version of Node.js on your system.
Conclusion
That’s it! You have successfully installed NVM on your Mac. Now you can easily manage and switch between different versions of Node.js and npm. Happy coding!