【软件版本说明】

软件名 版本号
nodejs 8.9.3

1.一键安装nodejs脚本

  1. #!/bin/bash
  2. sudo wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-linux-x64.tar.xz
  3. sudo tar -xJf node-v8.9.3-linux-x64.tar.xz
  4. sudo mv node-v8.9.3-linux-x64 /opt/
  5. sudo ln -s /opt/node-v8.9.3-linux-x64/bin/node /usr/local/bin/node
  6. sudo ln -s /opt/node-v8.9.3-linux-x64/bin/npm /usr/local/bin/npm
  7. #set environment
  8. export NODE_HOME="/opt/node-v8.9.3-linux-x64/bin/node"
  9. if ! grep NODE_HOME="/opt/node-v8.9.3-linux-x64/bin/node" /etc/profile
  10. then
  11. echo "NODE_HOME=/opt/node-v8.9.3-linux-x64/bin/node" | sudo tee -a /etc/profile
  12. echo "export NODE_HOME" | sudo tee -a /etc/profile
  13. echo "PATH=${NODE_HOME}/bin:$PATH" | sudo tee -a /etc/profile
  14. echo "export PATH" | sudo tee -a /etc/profile
  15. fi
  16. source /etc/profile
  17. sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
  18. sudo ln -s /opt/node-v8.9.3-linux-x64/lib/node_modules/cnpm/bin/cnpm /usr/local/bin/cnpm
  19. #更改node目录的权限
  20. sudo chown -R root /opt/node-v8.9.3-linux-x64/{lib/node_modules,bin,share}
  21. echo "isnatll nodejs is ok!!!"
  22. sudo node -v
  23. sudo npm -v
  24. sudo cnpm -v

2.【推荐】更快安装nodejs-16

  1. curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
  2. sudo apt-get install -y nodejs yarn

1.安装yarn

  1. curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
  2. echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  3. sudo apt update
  4. sudo apt install -y yarn

2.设置yarn为淘宝

  1. yarn config set registry http://registry.npm.taobao.org/