Ubantu nodejs卸载与二进制安装
#apt-get 卸载
sudo apt-get remove --purge npm
sudo apt-get remove --purge nodejs
sudo apt-get remove --purge nodejs-legacy
sudo apt-get autoremove
#手动删除 npm 相关目录
rm -r /usr/local/bin/npm
rm -r /usr/local/lib/node-moudels
find /usr -name npm
rm -r /tmp/npm*
二进制包,无须再编译
wget https://nodejs.org/dist/v14.17.5/node-v14.17.5-linux-x64.tar.xz
解压后加入环境变量
export PATH=/opt/app/node-v14.17.5-linux-x64/bin:$PATH
# node -v
v14.17.5
# npm -v
6.14.14
npm config set prefix "/opt/app/node-v14.17.5-linux-x64/node_global" npm config set cache "/opt/app/node-v14.17.5-linux-x64/node_cache"