Node.js Environment Setup - Installing LTS via NVM, NPM & VS Code Configuration

Setting up a clean, professional Node.js development environment is the foundation of every backend developer's journey. In this tutorial, you will install Node.js Long Term Support (LTS) using Node Version Manager (NVM), verify your NPM installation, and configure Visual Studio Code with the best developer extensions.

Method 1: Installing via NVM (Recommended for Developers)

Directly downloading an installer from nodejs.org often causes permission errors when installing global tools and makes it difficult to test projects requiring different Node versions. NVM solves this cleanly.

On Windows (using nvm-windows):

  1. Download the latest installer from the official repository: github.com/coreybutler/nvm-windows/releases.
  2. Run nvm-setup.exe and follow the standard installation wizard.
  3. Open PowerShell or Command Prompt and install the latest LTS release:
    nvm install lts
    nvm use lts

On macOS and Linux:

# Download and install nvm via curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

# Reload your shell profile (.bashrc or .zshrc)
source ~/.bashrc

# Install and activate the latest active LTS version
nvm install --lts
nvm use --lts

Verifying Your Node.js and NPM Installation

Run the following verification commands in your terminal:

node --version
# Output: v22.11.0 (or current LTS)

npm --version
# Output: 10.9.0 (or current version)

npx --version
# Output: 10.9.0
Pro Tip: Global Package Location

When using NVM, global NPM packages are installed inside the specific active Node version directory, eliminating the dreaded EACCES: permission denied errors common on Linux and macOS.

Configuring Visual Studio Code for Node.js

Visual Studio Code is the gold-standard editor for JavaScript and Node development. Install the following essential extensions from the VS Code Marketplace:

  • ESLint: Automatically enforces clean code standards and catches syntax bugs in real-time.
  • Prettier - Code Formatter: Keeps indentation, semicolons, and code aesthetics consistent across your team.
  • REST Client: Allows testing HTTP endpoints directly inside .http files without needing third-party Postman software.
  • DotENV: Syntax highlighting for .env environment variable files.

Creating a VS Code Debugging Profile (launch.json)

To debug Node.js code with breakpoints instead of relying solely on console.log, create a .vscode/launch.json file in your project root:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "skipFiles": ["<node_internals>/**"],
      "program": "${workspaceFolder}/index.js",
      "restart": true,
      "console": "integratedTerminal"
    }
  ]
}

Frequently Asked Questions (FAQ) - Student & Interview Review

Q1. Why is installing Node.js via NVM better than the standard installer?

Node Version Manager (NVM) allows you to install multiple versions of Node.js on a single machine and switch between them instantly with a single command. It also avoids permission issues (sudo/admin privileges) when installing global NPM packages.

Q2. What is the difference between Node.js LTS and Current releases?

LTS (Long Term Support) releases prioritize enterprise stability, performance, and security patches for at least 30 months. Current releases include cutting-edge ECMAScript features and experimental APIs that may change, making LTS the industry standard for production and university learning.

Q3. How do I verify that Node.js and NPM are installed properly?

Open your terminal or command prompt and run 'node -v' and 'npm -v'. If both commands return version numbers (e.g., v22.11.0 and 10.9.0), your installation is completely successful.

Explore Related Node.js Tutorials & Next Steps

Boost your server-side JavaScript proficiency by studying these closely connected core modules:

Creating Your First Node App

Run your first script and inspect console outputs.

Node.js REPL & CLI Flags

Interactive command-line execution and inspector flags.

NPM & package.json Guide

Initialize packages, manage dependencies, and write scripts.

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!