ComputerMacWindows

How to Install Node Version Manager (NVM) MacOS and Windows

Node Version Manager (NVM) on MacOS and Windows: Node.js is a cross-platform, open-source JavaScript runtime environment that operates on Chrome’s V8 JavaScript engine and enables the execution of JavaScript code outside the context of a web browser, such as on a server. It makes Node.js an ideal tool for creating server-side application developers.

In the Stack Overflow Developer Survey, Node.js has been recognized as the most popular web framework among professional developers and developers learning to code.

Since Node.js is continually developed and enhanced, new versions of Node.js are periodically released. It frequently results in adding new features to the framework, discontinuing some older features, or changing how certain framework functionalities are implemented.

It means that as developers create applications with Node.js, they are implemented with various Node.js versions.

In turn, it means that an application developed with a specific version of Node.js, such as Node.js version 9.x, may produce unexpected outcomes or errors when executed with a different version of Node.js, such as Node.js version 20.x.

As you work on various Node.js projects, you must repeatedly deactivate your current Node.js version and install the required understanding to resolve the issue.

Developers may have to perform this numerous times when they transfer projects, which may be uncomfortable and exhausting. Using the Node Version Manager (NVM) is a more efficient method.

The Node Version Manager (NVM) is a command-line tool that helps install and manage multiple versions of Node.js on a computer. In addition, it allows you to effortlessly transition between the various Node.js versions installed on your computer. It makes nvm an essential value for anyone working with Node.js, even if they have yet to work on projects using various Node.js versions.

How to Install Node Version Manager (NVM)

Let’s review how to install nvm on Windows and MacOS.

1. Prerequisites for installing NVM

Ensure you uninstall any existing Node.js versions before installing nvm to avoid conflicts. If you are using Windows, you should delete the directory in which Node.js was installed. It is typically the nodejs folder within program files

Before installing nvm on MacOS, you must manually install the Xcode command-line tools.

The installation will fail otherwise. It will be covered in the section describing how to install nvm on macOS. Installing Xcode command line tools requires MacOS version 13 or later and approximately 2.5 GB of available disk space.

2. Installing NVM on Windows

The original Node Version Manager was designed only for Linux and Mac operating systems, not Windows. In this regard, the NVM we will use on Windows differs from the nvm used on Linux and Mac.

However, Microsoft and Google both recommend the NVM for Windows operating systems.

To install NVM on your Windows computer, perform the steps below.

1. To view the nvm releases, visit nvm releases. Click the latest nvm-setup.exe file under Assets to obtain the newest nvm installer.

2. Open the installer once the installation is complete and select Yes when prompted to authorize the app to adjust your device.

3. Select I accept the license agreement and click Next on the License Agreement Screen.

4. On the Select Destination Location screen, specify where to install nvm for Windows and select Next.

5. On the Set Node.js Symlink screen, specify the location where the Symlink should be created, then select Next. It is the location of the active version of Node.js.

6. Now that everything has been prepared, it is time to install nvm. Click Install on the Ready to Install screen to install nvm on your system.

7. Once the installation is complete, select Finish.

8. To verify the installation was finished, Launch Windows PowerShell with Administrator rights.

Once within Powershell, run.

nvm -v

If the installation was successful, a screen displaying the version number of the installed nvm should appear.

After installing nvm, you can utilize it to install and administer multiple versions of Node.js

3. Installing NVM on macOS

You should install nvm on MacOS directly from GitHub and not through Homebrew, the package manager for macOS. You must also manually install the Xcode command line utilities on your computer. Installing Xcode command line tools is our first step. To do this, please follow these steps:

1. Go to the Apple developers’ download page.

2. Search for Xcode Command Line Tools. Download the most recent version that is not a beta or release candidate version.

3. Open the downloaded.dmg file and execute tools.pkg file titled Command Line tools. It begins with the installer for command line services.

4. Press Continue

5. On this screen, you can also alter your preferred language.

6. Click Accept to proceed with the installation, then click Install to install the command line utilities.

7. After installing command line tools, the next stage is to install nvm on a Mac. To accomplish this, please follow these steps:

8. Open the terminal and execute .zshrc in your Mac’s home directory to determine if it exists.

ls -a

9. By executing, create a .zshrc file if you don’t see one in your home directory.

touch ~/.zshrc

10. Copy and execute the following command in your terminal:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash

11. The preceding command downloads and executes a script. This script installs nvm on your Mac by cloning the nvm repository.

12. To verify that nvm has been executed, perform the command below in your terminal:

nvm -v

13. If a version number is displayed, the installation is successful.

Conclusion

The node version manager is an essential application for developers working with Node.js because it enables you to manage and transition between various Node.js versions effortlessly. If you are a developer working with the Node.js framework, consider installing nvm.

Related Articles

Back to top button