Loading

Linux安装node

说明

  1. 亲测在Ubuntu环境下安装成功
  2. 如果包管理器中有合适版本建议使用apt-getyum等命令直接安装

以Ubuntu系统为例,可以使用如下命令查看nodejs版本
sudo apt-get update -y
apt-cache policy nodejs
如果版本合适可直接使用命令安装,无需再阅读本教程
sudo apt-get install nodejs -y

安装步骤

nodejs安装包下载地址

https://registry.npmmirror.com/binary.html?path=node

使用命令下载

wget https://registry.npmmirror.com/-/binary/node/latest-v16.x/node-xxx.tar.xz

下载后的解压命令

tar -xvf node-xxx.tar.xz -C /usr

重命名文件夹(建议用版本号命名,如下)

cd /usr
mv node-xxx node16

执行命令查看node版本

/usr/node16/bin/node -v

设置软连接

ln -s /usr/node16/bin/npm /usr/local/bin/
ln -s /usr/node16/bin/node /usr/local/bin/

最后查看版本

cd /
node -v
npm -v

没有报错则代表安装完成了。

posted @ 2023-01-03 10:24  碌云  阅读(547)  评论(0编辑  收藏  举报