netnr / install-nodejs
2019-02-18 09:15

linux安装nodejs

# 方式1:yum安装
# V10.x:
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
# V8.x:
curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
# V7.x:
curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
# V6.x:
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
# V5.x:
curl --silent --location https://rpm.nodesource.com/setup_5.x | bash -
# 安装
yum install nodejs
# help
https://github.com/nodesource/distributions

# 显示版本
node -v




# 方式2:下载解压
https://nodejs.org/en/download/
http://nodejs.cn/download/

# 下载、解压
wget https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
tar -xvf node-v10.15.1-linux-x64.tar.xz
# 修改文件夹
mv node-v10.15.1-linux-x64 nodejs
# nodejs下bin目录是否有node 和npm
# 建立软连接,变为全局
ln -s /netnr/run/nodejs/bin/npm /usr/local/bin/
ln -s /netnr/run/nodejs/bin/node /usr/local/bin/
ˆ