Linux 安装 Nodejs

下载Nodejs

image.png

# wget https://npmmirror.com/mirrors/node/v20.11.1/node-v20.11.1-linux-x64.tar.xz

安装

# xz -d node-v20.11.1-linux-x64.tar.xz
# tar -xf node-v20.11.1-linux-x64.tar.xz
# mv node-v20.11.1-linux-x64 /usr/local/nodejs
# ln -s /usr/local/nodejs/bin/node /usr/bin/node
# ln -s /usr/local/nodejs/bin/npm /usr/bin/npm
# ln -s /usr/local/nodejs/bin/npm /usr/bin/npx
  • 安装 pnpm
# npm install -g pnpm
# ln -s /usr/local/nodejs/bin/pnpm /usr/bin/pnpm
  • 配置阿里镜像源
# npm config set registry https://registry.npmmirror.com
# pnpm config set registry https://registry.npmmirror.com

检查是否安装成功

# node -v
v20.11.1
# npm -v
10.2.4
# npx -v
10.2.4
# pnpm -v
8.15.5
  • 检查镜像源
# npm config get registry
https://registry.npmmirror.com
# pnpm config get registry
https://registry.npmmirror.com


标题:Linux 安装 Nodejs
作者:Mune
地址:https://cnxiaobai.com/articles/2021/05/18/1621338725156.html

    评论
    0 评论
avatar

取消