以下是在Ubuntu上搭建Node.js环境的几种方法:
sudo apt update
。sudo apt install nodejs npm
。node -v
和npm -v
。curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
。sudo apt-get install -y nodejs
。node -v
和npm -v
。curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
。source ~/.bashrc
。nvm install --lts
。node -v
,并可通过nvm use
切换版本。