yum安裝新版nodejs

官網(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月。

下載鏈接

Node.js網(wǎng)站

在Ubuntu 18.04系統(tǒng)中安裝Node.js 10的方法

在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。

|

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容