【软件版本说明】
软件名 | 版本号 |
---|---|
nodejs | 8.9.3 |
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
2.【推荐】更快安装nodejs-16
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt-get install -y nodejs yarn
1.安装yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install -y yarn
2.设置yarn为淘宝
yarn config set registry http://registry.npm.taobao.org/