1.查看 node 的官网:https://nodejs.org/en/download/
2.使用 wget 命令去下载 node,获取最新的 node.js 版本
#先进入local文件下
cd /usr/local
#创建node的文件夹
mkdir node
#然后进入node文件下
cd node
#在node文件下使用wget命令下载node包
wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.xz
3.解压当前的压缩包
tar -xvf node-v16.17.0-linux-x64.tar.xz
这个文件是已经编译好的 node 文件,不需要再去编译,只要在环境变量中配置一下就可以使用
#修改etc下的profile文件
vim /etc/profile
4.在 profile 文件的最后位置加上这个配置即可
export PATH=$PATH:/usr/local/node/node-v14.15.3-linux-x64/bin
注意:这个路径是解压后的文件下 bin 的路径,以你自己的路径为准
5.最后 source 一下这个文件,让这个文件生效
source /etc/profile