Node.js安装配置手册

依次执行下列四步命令:

apt update && apt install -y ca-certificates curl gnupg
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list

更新软件:apt update

安装Node.js:apt install nodejs -y

验证安装:

node -v
npm -v

设置淘宝镜像源:npm config set registry https://registry.npmmirror.com

验证安装:npm config get registry

回归官方源:npm config set registry https://registry.npmjs.org

  • docs/env/nodejs.txt
  • 最后更改: 2025/03/14 17:56
  • ossdate