How important is next in Node js

Install NodeJS on Windows

  • 5 minutes to read

If you are new to developing with Node.js and want to get started quickly so you can learn, follow these steps to install Node.js directly on Windows.

Note

If you are a professional at using Node.js, you think performance speed and system call compatibility are important, want to run Docker containers that consume Linux workspaces and avoid having to manage both Linux and Windows build scripts, or just use them If you prefer a bash command line, then install Node.js on Windows Subsystem for Linux (WSL 2 to be precise).

Install nvm-windows, Node.js and npm

In addition to choosing whether to install on Windows or WSL, there are other options when installing Node.js. Using a version manager is recommended as versions change very quickly. You will likely need to switch between different versions of Node.js depending on the needs of each project you're working on. Node Version Manager (commonly referred to as “nvm”) is the most popular way to install multiple versions of Node.js, but it is only available for Mac and Linux and is not supported on Windows. Instead, the steps to install nvm-windows are run through here in order to then install Node.js and Node Package Manager (npm). There are alternate version managers, which are covered in the next section.

Important

It is always recommended to remove existing installations of Node.js or npm from the operating system before installing a version manager, as the different installation types can lead to unusual and confusing conflicts. This also includes deleting the existing nodejs installation directories (e.g. "C: \ Program Files \ nodejs") that may remain. The symlink generated by nvm does not overwrite existing (even empty) installation directories. For help removing previous installations, see Removing Node.js From Windows Completely.)

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

  2. Load the file nvm-setup.zip for the latest release.

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

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

  5. When the installation is complete, do the following: Open PowerShell and use windows-nvm to list which versions of Node are currently installed (none at this time):

  6. Install the latest release of Node.js (for testing the latest feature improvements, but which is more likely to contain bugs than the LTS version):

  7. Install the latest stable LTS release of Node.js (recommended) by first looking for the current LTS version number:. Then install this LTS version number with: (replace with the version number, i.e.).

  8. List the installed versions of Node:. The two versions you just installed should now be listed.

  9. After installing the required Node.js version numbers, select the version you want by typing: (where will be replaced by the number, so).

  10. To change the version of Node.js that you want to use for a project, create a new project directory and switch to the directory (). Then enter, and replace with the desired version number (e.g. "v10.16.3").

  11. Use to check which version of npm is installed. This version number is automatically changed to the npm version associated with your current version of Node.js.

Alternative version manager

Although windows-nvm is currently the most popular version manager for Node, there are alternatives:

  • nvs (Node Version Switcher) is a cross-platform alternative to with the possibility of integration with VS Code.

  • Volta is a new version manager on the LinkedIn team that is promoting with faster speed and cross-platform support.

To install Volta as a version manager (instead of windows-nvm), go to the section Windows installation in the getting started guide. Then download and run the Windows installer and follow the setup instructions.

Important

Before installing Volta, you need to make sure that developer mode is enabled on your Windows computer.

For more information on using Volta to install multiple versions of Node.js on Windows, see the Volta documentation.

Install Visual Studio Code

It is recommended that you install Visual Studio Code and the Node.js extension package for developing with Node.js on Windows. Either install everything or choose which components are most useful to you.

How to install the Node.js extension package

  1. In VS Code, open the window Extensions (CTRL + SHIFT + X).
  2. In the search box at the top of the Extensions window, type: Node Extension Pack (or the name of the extension you want).
  3. Choose To install out. After the installation, the extension will appear in the window Extensions displayed in the “Activated” folder. You can disable, uninstall, or configure settings by selecting the gear icon next to the description of the new extension.

You should also consider the following additional extensions:

  • Debugger for Chrome: After you have completed the server-side development with Node.js, you need to develop and test the client-side. This extension integrates your VS Code editor with your Chrome browser's debug service so you can work more efficiently.
  • Keyboard layouts from other editors: These extensions make it easier to work in your environment if you switch from another text editor (e.g. Atom, Sublime, Vim, emacs, Notepad ++, etc.).
  • Settings Sync: This allows you to sync the VS Code settings in different installations via GitHub. This way, if you work on different computers, you can keep the environment consistent.

Alternative code editors

If you prefer to use a code editor or IDE other than Visual Studio Code, the following options are also for your Node.js development environment:

Install Git

If you intend to collaborate with others or host the project in an open source location (like GitHub), VS Code supports version control with Git. The Source Control tab in VS Code keeps track of all changes and common Git Commands ("Add", "Commit", "Push", "Pull") integrated directly into the user interface. You must first install Git to enable the Source Control section.

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

  2. An installation wizard is included that asks you a series of questions about the settings for the Git installation. You should use all of the default settings unless you have a specific reason to change something.

  3. If you've never used Git before, you can use GitHub guides to get started.

  4. It is recommended to add a .gitignore file to your node projects. This is the GITIGNORE default template for Node.js from GitHub.

Using the Windows Subsystem for Linux for Production

Using Node.js directly on Windows is great for learning and experimenting with the possibilities. When you're ready to build production-ready web apps, which are typically hosted on a Linux-based server, consider the Windows Subsystem for Linux Version 2 (WSL 2) for developing Node.js web apps use. Many Node.js packages and frameworks are built for a * nix environment, and most of the Node.js apps are deployed on Linux. Development in the WSL therefore ensures consistency between your development environment and the production environment. For information on setting up a WSL development environment, see Setting up the Node.js development environment with WSL 2.