This guide will help you set up a complete development environment on Linux (Ubuntu/Debian) with:
- Node.js + npm using NVM (Node Version Manager)
- Visual Studio Code
- MongoDB Community Edition
This setup is designed for developers starting from scratch.
First, ensure your system is up to date.
sudo apt-get update -y
sudo apt-get upgrade -yNVM allows you to install and manage multiple versions of Node.js. This is preferred over installing Node.js directly with apt.
# Download and install NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Load NVM (you may need to restart your terminal afterwards)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"# Install latest LTS version of Node.js
nvm install --lts
# Use the installed version
nvm use --lts
# Verify installation
node -v
npm -vWe’ll install VS Code directly from Microsoft’s repository.
# Install wget and gpg if missing
sudo apt-get install -y wget gpg
# Import Microsoft GPG key
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /usr/share/keyrings/packages.microsoft.gpg
# Add VS Code repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" | \
sudo tee /etc/apt/sources.list.d/vscode.list
# Update and install VS Code
sudo apt-get update
sudo apt-get install -y codecode- Prettier – Code Formatter
- ESLint
- MongoDB for VS Code
We’ll install MongoDB 7.0 and run it locally.
# Import MongoDB public GPG key
curl -fsSL https://pgp.mongodb.com/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor
# Add MongoDB repository
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/7.0 multiverse" | \
sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
# Update and install MongoDB
sudo apt-get update
sudo apt-get install -y mongodb-org
# Start MongoDB service
sudo systemctl start mongod
sudo systemctl enable mongod
# Check status
sudo systemctl status mongodmongoshnode -v
npm -vecho 'console.log("✅ Node.js is working!")' > test.js
node test.jsmongoshYou should see the MongoDB shell prompt.
-
Use NVM to switch Node.js versions easily:
nvm install 20 # Install Node.js 20 nvm use 20 # Switch to Node.js 20
-
Use VS Code as your editor (
code .inside any project folder). -
Use MongoDB locally for your database.
Happy coding! 🎉