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
bashnode --version # v20.x.x npm --version # 10.x.x
Why nvm
- Switch between Node versions per project.
- No
sudoheadaches. - 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
bashnpm 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
bashcurl -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
bashcurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt install -y nodejs node -v && npm -v
Linux (Fedora / RHEL)
bashsudo dnf module install -y nodejs:20 node -v && npm -v
Verify
bashmkdir 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?
