Cài nodejs trên môi trường Ubuntu
Nguyễn Quang Minh
•
1 min read
•4 views
Để cài Node.js trên Ubuntu (ổn định, cập nhật), bạn nên dùng NodeSource hoặc nvm
. Dưới đây là 2 cách phổ biến:
✅ Cách 1: Dùng NodeSource (ổn định, đơn giản)
# Cài curl nếu chưa có
sudo apt update
sudo apt install curl -y
# Thêm Node.js 18 LTS (hoặc 20 nếu bạn muốn)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
🔍 Kiểm tra phiên bản:
node -v
npm -v
Nếu muốn Node 20:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
✅ Cách 2: Dùng NVM (quản lý nhiều version Node)
# Cài nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
# Tải lại shell config
source ~/.bashrc # hoặc ~/.zshrc nếu dùng zsh
# Cài Node.js phiên bản mới nhất LTS
nvm install --lts
# Dùng Node mặc định mỗi lần mở terminal
nvm alias default lts/*
🔍 Kiểm tra:
node -v
npm -v
⚠️ Nếu dùng server (VD: VPS, DigitalOcean...)
Nên dùng NodeSource nếu bạn chỉ cần 1 version Node ổn định.
Nên dùng NVM nếu bạn làm dev nhiều dự án hoặc muốn chuyển version nhanh chóng
Nguyễn Quang Minh
Passionate developer and writer sharing insights about technology, programming, and digital innovation. Follow for more content about web development and tech trends.
1.2K followers