linux-tutorial/codes/linux/ops/service/nodejs/install-nodejs.sh

27 lines
677 B
Bash
Raw Normal View History

2018-02-01 16:34:02 +08:00
#!/usr/bin/env bash
###################################################################################
# 安装 Nodejs 脚本
# 适用于所有 linux 发行版本。
# Author: Zhang Peng
###################################################################################
2018-02-01 16:34:02 +08:00
echo -e "\n>>>>>>>>> install node.js"
2018-02-01 16:34:02 +08:00
. ~/.nvm/nvm.sh
nvm --version
execode=$?
2019-02-22 18:02:38 +08:00
if [[ ${execode} != 0 ]]; then
echo -e "\n未找到 nvm ,开始安装"
echo -e "\n>>>>>>>>> install nvm"
rm -rf ~/.nvm
2018-10-25 10:12:37 +08:00
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
. ~/.nvm/nvm.sh
nvm --version
fi
version=8.9.4
nvm install ${version}
nvm use ${version}
node --version