官網(wǎng)安裝說明:CentOS 安裝 nodejs
系統(tǒng)的yum源安裝nodejs版本太低。如果你的系統(tǒng)版本比較低,gcc庫版本低,編譯安裝的時(shí)候有可能不成功,下面是yum安裝的步驟
第一步:
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash
## Installing the NodeSource Node.js 10.x repo...
## Inspecting system...
+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release
+ uname -m
## Confirming "el6-x86_64" is supported...
+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_10.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'
## Downloading release setup RPM...
+ mktemp
+ curl -sL -o '/tmp/tmp.aoQY5ifb9m' 'https://rpm.nodesource.com/pub_10.x/el/6/x86_64/nodesource-release-el6-1.noarch.rpm'
## Installing release setup RPM...
+ rpm -i --nosignature --force '/tmp/tmp.aoQY5ifb9m'
## Cleaning up...
+ rm -f '/tmp/tmp.aoQY5ifb9m'
## Checking for existing installations...
+ rpm -qa 'node|npm' | grep -v nodesource
## Run `sudo yum install -y nodejs` to install Node.js 10.x and npm.
## You may also need development tools to build native addons:
sudo yum install gcc-c++ make
## To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
第二步:
sudo yum -y install nodejs
如果以上步驟不能安裝 最新版 node,執(zhí)行以下命令后再執(zhí)行第二步:
sudo yum clean all
如果存在多個(gè) nodesoucre,執(zhí)行以下命令刪除,然后重新執(zhí)行第一第二步:
sudo rm -fv /etc/yum.repos.d/nodesource*
Ubuntu系統(tǒng)安裝nodejs
以下介紹的安裝Node.js 10方法適用在Ubuntu 18.04/Ubuntu 16.04/Debian 9系統(tǒng)中。Node.js 10是一個(gè)LTS版本,它從Node v10.13.0開始成為LTS版本,這個(gè)版本的Node(Dubnium)將一直支持到2020年4月。
下載鏈接
在Ubuntu 18.04系統(tǒng)中安裝Node.js 10的方法
1、要在Ubuntu 18.04/Ubuntu 16.04/Debian 9中安裝Node.js 10.x LTS,請(qǐng)?zhí)砑覰odeSource二進(jìn)制分發(fā)存儲(chǔ)庫:
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash
此命令將Node.js APT存儲(chǔ)庫配置到你的操作系統(tǒng)。
2、添加存儲(chǔ)庫后,使用apt包管理器在Ubuntu 18.04/Ubuntu 16.04/Debian 9中安裝Node.js 10 LTS:
sudo apt update
sudo apt -y install gcc g++ make
sudo apt -y install nodejs
3、要安裝Yarn包管理器,請(qǐng)運(yùn)行:
curl -sL 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-get update && sudo apt-get install yarn
4、確認(rèn)Node版本,請(qǐng)運(yùn)行:
$ node -v
v10.17.0
從返回的信息上看,所安裝的版本是Node.js 10.17.0。
|