Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 05 / 4711%· free preview
Introduction to Node.js5/6

Installing Node.js and npm

Installation
Recommended: nvm (Node Version Manager)
bash
# macOS / Linux
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install --lts
nvm use --lts

# Windows: use nvm-windows from GitHub
Verify
bash
node --version    # v20.x.x
npm  --version    # 10.x.x
Why nvm
  • Switch between Node versions per project.
  • No sudo headaches.
  • Easy upgrade: nvm install --lts && nvm alias default lts/*.
Alternatives
  • Official installer from nodejs.org (simplest, one version).
  • Package managers: brew install node (macOS), apt install nodejs npm (Ubuntu).
  • Docker: FROM node:20-alpine.
Configuring npm
bash
npm config set init-author-name  "Your Name"
npm config set init-license      "MIT"
npm config get cache             # where downloads live
Interview Questions

OS-specific Install Steps

We recommend using nvm (Node Version Manager) so you can switch versions per project.

Windows
powershell
# nvm-windows from https://github.com/coreybutler/nvm-windows
winget install -e --id CoreyButler.NVMforWindows
# Reopen terminal
nvm install lts
nvm use lts
node -v && npm -v
macOS / Linux
bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# restart your shell
nvm install --lts
node -v && npm -v
Linux (Ubuntu / Debian) — system package alternative
bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt install -y nodejs
node -v && npm -v
Linux (Fedora / RHEL)
bash
sudo dnf module install -y nodejs:20
node -v && npm -v
Verify
bash
mkdir hi && cd hi && npm init -y
echo "console.log('Hello, Node.js!')" > index.js
node index.js
AI-powered recap

Quick recap quiz?

We'll generate 5 MCQs from this lesson and check your understanding instantly. Takes ~30 seconds.

Ready to move on?
// feedback.matters()
Did this lesson help you?