一,访问官网
https://nodejs.org/en
得到下载包地址:
二,下载/解压
下载:
root@lhdpc:/usr/local/source/node# wget https://nodejs.org/dist/v18.17.1/node-v18.17.1-linux-x64.tar.xz
解压:
root@lhdpc:/usr/local/source/node# xz -d node-v18.17.1-linux-x64.tar.xz
root@lhdpc:/usr/local/source/node# tar -xvf node-v18.17.1-linux-x64.tar
三,安装:
1,移动目录:
root@lhdpc:/usr/local/source/node# mv node-v18.17.1-linux-x64 /usr/local/soft/
2,创建符号链接:
删除以前的链接
root@lhdpc:/usr/local/source/node# rm /usr/local/bin/node
root@lhdpc:/usr/local/source/node# rm /usr/local/bin/npm
创建符号链接供命令行使用
root@lhdpc:/usr/local/source/node# ln -s /usr/local/soft/node-v18.17.1-linux-x64/bin/node /usr/local/bin/node
root@lhdpc:/usr/local/source/node# ln -s /usr/local/soft/node-v18.17.1-linux-x64/bin/npm /usr/local/bin/npm
3,查看安装后的版本
root@lhdpc:/usr/local/source/node# node -v
v18.17.1
root@lhdpc:/usr/local/source/node# npm -v
9.6.7
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/09/06/ubuntu-linux-an-zhuang-node-v18-17-1/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]
四,配置npm使用taobao源:
查看当前的registry
root@lhdpc:/usr/local/source/node# npm config get registry
https://registry.npmjs.org/
设置当前的registry
root@lhdpc:/usr/local/source/node# npm config set registry https://registry.npm.taobao.org
查看设置后的registry,可见已设置成功
root@lhdpc:/usr/local/source/node# npm config get registry
https://registry.npm.taobao.org
五,升级npm:
查看当前npm版本:
root@lhdpc:/usr/local/source/node# npm -v
9.6.7
升级
root@lhdpc:/usr/local/source/node# npm install -g npm
removed 12 packages, and changed 76 packages in 4s
28 packages are looking for funding
run `npm fund` for details
查看升级后的版本:
root@lhdpc:/usr/local/source/node# npm -v
10.0.0
标签:node,npm,source,v18.17,usr,lhdpc,linux,local
From: https://www.cnblogs.com/architectforest/p/17684566.html