100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Node.js

Setting Up a Node.js Environment

Install Node.js, choose an LTS version, and configure a basic project structure ready for development.

Introduction to Node.jsBeginner7 min readJul 8, 2026
Analogies

Introduction

Before writing Node.js applications, you need a properly configured development environment. This involves installing Node.js itself (which bundles npm), choosing an appropriate version, and setting up a basic project structure. Node.js releases follow a predictable schedule: even-numbered major versions (e.g. 18, 20, 22) become Long-Term Support (LTS) releases, recommended for production use because they receive stability and security updates for an extended period.

🏏

Cricket analogy: Before stepping onto the pitch, a player needs the right kit fitted and checked, much like installing Node.js and npm before coding; and just as international teams trust players with several seasons of proven form (the even-numbered LTS releases), production apps trust the stable, long-supported Node versions.

How It Works

Node.js can be installed directly from nodejs.org, via an OS package manager, or — the recommended approach for developers — via a version manager like nvm (Node Version Manager). A version manager lets you install and switch between multiple Node.js versions on the same machine, which is essential when different projects require different versions.

🏏

Cricket analogy: Node.js can be installed straight from the official source like buying gear from the official kit supplier, through a general store like an OS package manager, or -- the pro's choice -- through a kit manager like nvm that lets a player switch between different bat weights (Node versions) for different match formats.

bash
# Install nvm (Linux/macOS), then:
nvm install --lts
nvm use --lts
node --version
npm --version

Explanation

nvm install --lts downloads and installs the latest LTS release of Node.js, and nvm use --lts activates it for the current shell session. Once installed, node --version and npm --version confirm the active versions. A typical new project is initialized with npm init -y to generate package.json, followed by creating an entry file (commonly index.js or app.js) and a .gitignore that excludes node_modules and environment files.

🏏

Cricket analogy: nvm install --lts is like ordering the latest officially approved match kit, and nvm use --lts is like suiting up in it for today's game; checking node --version and npm --version is like confirming your kit tag before walking out, and npm init -y is like filling out the team registration sheet before adding your squad list (a .gitignore excluding node_modules and env files, so you don't hand opponents your private strategy notes).

Example

bash
mkdir my-node-app && cd my-node-app
npm init -y
echo "node_modules/\n.env" > .gitignore
echo "console.log('App started');" > index.js
node index.js

Output

bash
Wrote to /path/my-node-app/package.json
App started

Key Takeaways

  • Use a version manager like nvm to install and switch between Node.js versions per project.
  • Prefer even-numbered LTS releases for production stability and long-term security updates.
  • npm init -y quickly scaffolds a package.json for a new project.
  • Always .gitignore node_modules and files containing secrets like .env.
  • Verify your setup with node --version and npm --version before starting development.

Practice what you learned

Was this page helpful?

Topics covered

#NodeJs#NodeJsExpressStudyNotes#WebDevelopment#SettingUpANodeJsEnvironment#Setting#Node#Environment#Works#StudyNotes#SkillVeris