Set Up a Local Node.js Development Environment on Windows 10/11 with NVM

  • Thread Author

Set Up a Local Node.js Development Environment on Windows 10/11 with NVM​

Difficulty: Beginner | Time Required: 25-35 minutes
Node.js is at the heart of many modern web apps, scripts, and tooling. Managing multiple Node.js versions on Windows can get tricky, especially when projects require different runtimes. Using NVM for Windows (the Windows port of Node Version Manager) makes it simple to install, switch between, and keep Node.js up to date—without messing with system PATHs. This guide walks you through a clean, beginner-friendly setup on Windows 10 or Windows 11.

Prerequisites​

  • A Windows 10 (Version 1809 or newer) or Windows 11 PC with an active internet connection.
  • Administrative rights to install software (or reach out to your IT admin if you’re on a work device).
  • A text editor or IDE (Visual Studio Code recommended) and a browser to test web apps.
Optional but helpful:
  • Basic familiarity with the Command Prompt or PowerShell.
  • Familiarity with npm packages and package.json.

Step-by-Step Instructions​

1) Check your Windows version
  • Press Win + R, type winver, and press Enter.
  • Ensure you’re on Windows 10 (Version 1809 or newer) or Windows 11. If not, update Windows before proceeding.
2) Remove any existing Node.js (optional but recommended)
  • Open Settings > Apps > Apps & features.
  • Look for entries like “Node.js” or “node” and uninstall them.
  • This avoids PATH conflicts with NVM-managed Node versions.
3) Download and install NVM for Windows
  • Go to the official NVM for Windows repository: github.com/coreybutler/nvm-windows
  • Download the latest release (the nvm-setup zip that contains nvm-setup.exe, or run the installer if you get it directly).
  • Run the installer. You’ll be prompted to:
    • Choose an install location for NVM (e.g., C:\nvm).
    • Choose where Node.js versions will be kept (NVM_SYMLINK; typically C:\Program Files\nodejs or a path you prefer).
  • Complete the installation. Restart your terminal after the setup finishes if prompted.
4) Verify NVM installation
  • Open a new Command Prompt or PowerShell window.
  • Type:
    • nvm version
    • nvm list available
  • If you see version information and a list of available Node.js releases, you’re ready to install Node.js versions.
5) Install Node.js versions with NVM
  • Decide which Node.js versions you need (LTS is a good default; e.g., Node 18.x or 16.x).
  • Install a version (example commands):
    • nvm install 18
    • nvm install 16
  • After each install, you can verify with:
    • nvm list
    • nvm use 18
    • node -v
  • To set a default version (the one you want when you open a new terminal), run:
    • nvm alias default 18
  • Open a new terminal and confirm the default Node version is active:
    • node -v
    • npm -v
      Note: npm comes bundled with Node.js, so installing Node.js via NVM automatically installs npm.
6) Create a small sample project to test
  • In your preferred development folder, run:
    • mkdir my-node-app
    • cd my-node-app
    • npm init -y
  • Install a basic package (optional for testing):
    • npm install express
  • Create a simple server (index.js) and run it:
    • echo "const express = require('express'); const app = express(); app.get('/', (req, res) => res.send('Hello Node with NVM!')); app.listen(3000, () => console.log('Server running on port 3000'));" > index.js
    • node index.js
    • Open http://localhost:3000 in your browser to verify.
7) Optional: Install a code editor
  • Download and install Visual Studio Code from code.visualstudio.com.
  • In VS Code, you can open the project folder and run debug tasks, or install Node.js-related extensions (ESLint, Prettier, npm Intellisense, etc.).
8) Keep Node versions organized
  • When you work on projects with different requirements, switch versions:
    • nvm use 16
    • nvm use 18
  • You can list installed versions with:
    • nvm list
    • Use "nvm alias default <version>" to set your preferred default version.

Tips and Troubleshooting Notes​

  • Restart after installation: If commands like nvm or node aren’t recognized, close all terminals and reopen a new one. Some PATH updates need a fresh shell.
  • PATH and permissions: If you see “not recognized” errors, verify that NVM and Node paths were added to your user PATH during install. If not, rerun the installer or manually add NVM_HOME and NVM_SYMLINK (as per the installer prompts).
  • Avoid conflicts with other Node installers: If you previously installed Node.js via the official installer, consider removing it (as shown in the prerequisites) to prevent PATH conflicts and confusing npm versions.
  • Choosing versions: For new projects, start with the latest LTS version (e.g., 18.x as of 2024-2025). For legacy projects, you may need an older LTS (e.g., 16.x).
  • Using WSL: If you later want a Linux-like environment, you can enable Windows Subsystem for Linux (WSL) and install Node inside the Linux distro. However, the NVM for Windows setup keeps your Windows-native development workflow simple and fast.
  • Editor tips: VS Code’s integrated terminal can switch Node versions too, but it relies on the system PATH. Using NVM in your shell ensures you’re always running the intended version.
  • Global packages: If you install global npm packages (like typescript, nodemon, eslint), each Node version has its own global space. Switch versions with nvm use before installing to keep environments isolated.

Conclusion​

By using NVM for Windows, you gain a clean, flexible way to manage multiple Node.js versions on Windows 10 or Windows 11. This setup reduces version conflicts across projects, makes testing across Node releases straightforward, and keeps your system tidy—no more hunting down which Node version is active. With Node.js installed via NVM, you can quickly spin up new projects, experiment with upcoming features, and maintain consistency across development teammates.
Key benefits include:
  • Easy multi-version management with simple commands
  • Quick switching between project-specific Node environments
  • Safe, isolated npm ecosystems per Node version
  • A straightforward path to testing across LTS releases

This tutorial was generated to help WindowsForum.com users get the most out of their Windows experience.
 

Back
Top