nodejs 安装到升级 排坑之旅
1下载
wget http://nodejs.org/dist/v0.10.33/node-v0.10.33-linux-x64.tar.gz
2解压
[root@bigData-02 ~]#
tar –zxvf node-v0.10.33-linux-x64.tar.gz
mv node-v0.10.33-linux-x64.tar.gz nodejs
3设置环境变量
vi /etc/profile
export NODE_HOME="/opt/nodejs"
export PATH=$PATH:$NODE_HOME/bin:$PATH
source /etc/profile
4检测是否正确安装
node -v
v0.10.33
npm -v
1.4.28
然后开始编译 提示npm版本太低需要升级
方法一: 用n升级nodejs
# 全局安装n
npm install -g n
# 升级到最新稳定版
n stable
然后报错:当发现nodejs -v显示的版本没有改变时,根据安装新版nodejs时的提示:
Note: the node command changed location and the old location may be remembered in your current shell.
old : /usr/bin/node
new : /usr/local/bin/node
To reset the command location hash either start a new shell, or execute PATH="$PATH"
需要将之前的配置的环境变量注释掉
Node 更新失败:cp cannot stat ‘usrlocalnversionsnode12
cp: cannot stat ‘/usr/local/n/versions/node/12.13.0/include’: No such file or directory
解决方案:
cd /usr/local/n/
rm -rf versions
在重新来
升级成功
https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xz