在Debian系统上搭建Node.js环境有多种方法,以下是几种常用的方法:
这是最简单的方法,适用于需要稳定版本且不经常更新Node.js的用户。
sudo apt update
sudo apt install nodejs npm
node --version npm --version
如果你需要安装特定版本的Node.js或最新的长期支持(LTS)版本,可以使用NodeSource提供的二进制分发库。
sudo apt install curl software-properties-common
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
node --version npm --version
NVM是一个用于管理Node.js版本的命令行工具,可以方便地安装、升级和切换Node.js版本。
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm ls-remote
nvm install --lts
nvm use 14.17.0
node --version npm --version
以上就是在Debian系统上搭建Node.js环境的几种常用方法。根据你的需求选择合适的方法进行安装即可。