install nodejs on Ubuntu

 

 

Option 1: NodeSource (system-wide, for production servers)

Good if you want a fixed version (LTS or Current).

  1. Update your package index:

 
sudo apt update sudo apt install -y curl
  1. Add the NodeSource repository (replace 20.x with 18.x or 22.x if you want a different line):

 
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
  1. Install Node.js + npm:

 
sudo apt install -y nodejs
  1. Verify:

 
node -v npm -v
 
 
来自chatgpt
posted @ 2025-09-05 01:39  profesor  阅读(7)  评论(0)    收藏  举报