Node Version Manager For Mac



-->

The following is a step-by-step guide to get you started using Node.js in a native Windows development environment.

Install nvm-windows, node.js, and npm

Mac

There are multiple ways to install Node.js. We recommend using a version manager as versions change very quickly. You will likely need to switch between multiple versions based on the needs of different projects you're working on. Node Version Manager, more commonly called nvm, is the most popular way to install multiple versions of Node.js, but is only available for Mac/Linux and not supported on Windows. Instead, we will walk through the steps to install nvm-windows and then use it to install Node.js and Node Package Manager (npm). There are alternative version managers to consider as well covered in the next section.

Important

Manage Node version by project. We’ve seen how to install Node versions via NVM and how to use the Node version via NVM. Next, let’s see how to manage the Node version by project. To manage the Node version by project, You need to create.nvmrc file. Create.nvmrc file on the root folder of the project, and modify it like below. How to install Node.js and NPM on Mac. On Mac, a user can install Node.js using the following approaches: Node installation using the “.pkg” installer. Installing a Node using “Homebrew.” Node installation using “Node Version Manager – NVM.” Let’s discuss all.

Node Version Manager For Mac

It is always recommended to remove any existing installations of Node.js or npm from your operating system before installing a version manager as the different types of installation can lead to strange and confusing conflicts. This includes deleting any existing nodejs installation directories (e.g., 'C:Program Filesnodejs') that might remain. NVM's generated symlink will not overwrite an existing (even empty) installation directory. For help with removing previous installations, see How to completely remove node.js from Windows.)

  1. Open the windows-nvm repository in your internet browser and select the Download Now link.

  2. Download the nvm-setup.zip file for the most recent release.

  3. Once downloaded, open the zip file, then open the nvm-setup.exe file.

  4. The Setup-NVM-for-Windows installation wizard will walk you through the setup steps, including choosing the directory where both nvm-windows and Node.js will be installed.

  5. Once the installation is complete. Open PowerShell and try using windows-nvm to list which versions of Node are currently installed (should be none at this point): nvm ls

  6. Install the current release of Node.js (for testing the newest feature improvements, but more likely to have issues than the LTS version): nvm install latest

  7. Install the latest stable LTS release of Node.js (recommended) by first looking up what the current LTS version number is with: nvm list available, then installing the LTS version number with: nvm install <version> (replacing <version> with the number, ie: nvm install 12.14.0).

  8. List what versions of Node are installed: nvm ls ...now you should see the two versions that you just installed listed.

  9. After installing the Node.js version numbers you need, select the version that you would like to use by entering: nvm use <version> (replacing <version> with the number, ie: nvm use 12.9.0).

  10. To change the version of Node.js you would like to use for a project, create a new project directory mkdir NodeTest, and enter the directory cd NodeTest, then enter nvm use <version> replacing <version> with the version number you'd like to use (ie v10.16.3`).

  11. Verify which version of npm is installed with: npm --version, this version number will automatically change to whichever npm version is associated with your current version of Node.js.

Alternative version managers

While windows-nvm is currently the most popular version manager for node, there are alternatives to consider:

Mac os nvm
  • nvs (Node Version Switcher) is a cross-platform nvm alternative with the ability to integrate with VS Code.

  • Volta is a new version manager from the LinkedIn team that claims improved speed and cross-platform support.

To install Volta as your version manager (rather than windows-nvm), go to the Windows Installation section of their Getting Started guide, then download and run their Windows installer, following the setup instructions.

Important

You must ensure that Developer Mode is enabled on your Windows machine before installing Volta.

To learn more about using Volta to install multiple versions of Node.js on Windows, see the Volta Docs.

Install your favorite code editor

We recommend you install VS Code, as well as the Node.js Extension Pack, for developing with Node.js on Windows. Install them all or pick and choose which seem the most useful to you.

To install the Node.js extension pack:

  1. Open the Extensions window (Ctrl+Shift+X) in VS Code.
  2. In the search box at the top of the Extensions window, enter: 'Node Extension Pack' (or the name of whatever extension you are looking for).
  3. Select Install. Once installed, your extension will appear in the 'Enabled' folder of your Extensions window. You can disable, uninstall, or configure settings by selecting the gear icon next to the description of your new extension.

A few additional extensions you may want to consider include:

  • Debugger for Chrome: Once you finish developing on the server side with Node.js, you'll need to develop and test the client side. This extension integrates your VS Code editor with your Chrome browser debugging service, making things a bit more efficient.
  • Keymaps from other editors: These extensions can help your environment feel right at home if you're transitioning from another text editor (like Atom, Sublime, Vim, eMacs, Notepad++, etc).
  • Settings Sync: Enables you to synchronize your VS Code settings across different installations using GitHub. If you work on different machines, this helps keep your environment consistent across them.

Install Git (optional)

If you plan to collaborate with others, or host your project on an open-source site (like GitHub), VS Code supports version control with Git. The Source Control tab in VS Code tracks all of your changes and has common Git commands (add, commit, push, pull) built right into the UI. You first need to install Git to power the Source Control panel.

Version
  1. Download and install Git for Windows from the git-scm website.

  2. An Install Wizard is included that will ask you a series of questions about settings for your Git installation. We recommend using all of the default settings, unless you have a specific reason for changing something.

  3. If you've never worked with Git before, GitHub Guides can help you get started.

  4. We recommend adding a .gitignore file to your Node projects. Here is GitHub's default gitignore template for Node.js.

Use Windows Subsystem for Linux for production

Using Node.js directly on Windows is great for learning and experimenting with what you can do. Once you are ready to build production-ready web apps, which are typically deployed to a Linux-based server, we recommend using Windows Subsystem for Linux version 2 (WSL 2) for developing Node.js web apps. Many Node.js packages and frameworks are created with a *nix environment in mind and most Node.js apps are deployed on Linux, so developing on WSL ensures consistency between your development and production environments. To set up a WSL dev environment, see Set up your Node.js development environment with WSL 2.

Note

If you are in the (somewhat rare) situation of needing to host a Node.js app on a Windows server, the most common scenario seems to be using a reverse proxy. There are two ways to do this: 1) using iisnode or directly. We do not maintain these resources and recommend using Linux servers to host your Node.js apps.

Before you can start making super awesome apps in NodeJS, you have to install it. Fortunately, installing NodeJS is super simple.

In this tutorial we will cover how to install NodeJS/NPM in

  • macOS/linux
  • Windows

Once you install NodeJS/NPM, you can easily upgrade/downgrade to any Node version with one command. The following video tutorial shows you how to download NodeJS on your machine.

Installation guide for Mac OS & Linux

Open a new terminal. Type the following and hit enter:

Close your terminal, then open a new one and type this:

You will see something like this:

Next in your terminal type:

Once it is installed, it is ready to be used. To use this version, just type this in your terminal:

Now that it is installed let's check it by doing the following:

And that is it – you are done. Have fun.

Now if, in the future, for some reason you want to uninstall NVM (node version manager) simply open up your terminal and type the following:

Installation guide for Windows

First, go to nvm-windows repositories releases section https://github.com/coreybutler/nvm-windows/releases. Select the latest release.

Next choose the nvm-setup.zip file and download it.

Once the file is downloaded, unzip and click on the installer and follow the steps. (I am using 7zip for .zip file extraction, because it is FREE.)

Then to check if nvm is properly installed, open a new command prompt terminal and type nvm. Once it is verified that it is installed you can move on to the next step.

Install NodeJS using nvm like this:

The version can be a NodeJS version or 'latest' (for the latest stable version).

In order to use the specific node version you just installed, in your terminal simply type the following:

Osx install nvm

Check the node version with node -v. This should output v12.18.1 in your terminal.

If you want to install another version of Node, repeat the steps with a different version.

Node Version Manager For Mac Catalina

You should now have a working version of NodeJS running on your machine. Happy coding folks. :)

Let me know if you found this guide helpful. Drop me a message on twitter (twitter.com/adeelibr).