【软件版本说明】
1.一键安装nodejs脚本
#!/bin/bash
sudo wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-linux-x64.tar.xz
sudo tar -xJf node-v8.9.3-linux-x64.tar.xz
sudo mv node-v8.9.3-linux-x64 /opt/
sudo ln -s /opt/node-v8.9.3-linux-x64/bin/node /usr/local/bin/node
sudo ln -s /opt/node-v8.9.3-linux-x64/bin/npm /usr/local/bin/npm
#set environment
export NODE_HOME="/opt/node-v8.9.3-linux-x64/bin/node"
if ! grep NODE_HOME="/opt/node-v8.9.3-linux-x64/bin/node" /etc/profile
then
echo "NODE_HOME=/opt/node-v8.9.3-linux-x64/bin/node" | sudo tee -a /etc/profile
echo "export NODE_HOME" | sudo tee -a /etc/profile
echo "PATH=${NODE_HOME}/bin:$PATH" | sudo tee -a /etc/profile
echo "export PATH" | sudo tee -a /etc/profile
fi
source /etc/profile
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
sudo ln -s /opt/node-v8.9.3-linux-x64/lib/node_modules/cnpm/bin/cnpm /usr/local/bin/cnpm
#更改node目录的权限
sudo chown -R root /opt/node-v8.9.3-linux-x64/{lib/node_modules,bin,share}
echo "isnatll nodejs is ok!!!"
sudo node -v
sudo npm -v
sudo cnpm -v