服务器版本
[root@izuf63g0jydq42k49eo7zcz ~]# uname -a Linux izuf63g0jydq42k49eo7zcz 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux [root@izuf63g0jydq42k49eo7zcz ~]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.4.1708 (Core) Release: 7.4.1708 Codename: Core [root@izuf63g0jydq42k49eo7zcz ~]# cat /proc/version Linux version 3.10.0-693.2.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Tue Sep 12 22:26:13 UTC 2017 [root@izuf63g0jydq42k49eo7zcz ~]#
安装脚本
#!/bin/bash #准备 yum install -y wget #下载安装 wget https://nodejs.org/dist/v10.15.3/node-v10.15.3-linux-x64.tar.xz mkdir -p /usr/local/nodejs tar -Jxvf node-v10.15.3-linux-x64.tar.xz -C /usr/local/nodejs/ #写入环境变量 echo "export PATH=/usr/local/nodejs/node-v10.15.3-linux-x64/bin:$PATH" >> /etc/profile source /etc/profile #查看版本信息 node -v npm version npx -v
修改权限
chmod +x node-install.sh
执行脚本
sh node-install.sh