如何在Linux(Ubuntu,Debian,Fedora,CentOS,RedHat)中安装Nodejs?

Nodejs is a platform built on Google Chrome Javascript runtime. Nodejs has different usage where Javascript traditionally used in client-side applications. Nodejs can be used in both client and server-side applications. In this tutorial, we will look at how to install Nodejs into Linux distributions like Ubuntu, Debian, Fedora, CentOS, RedHat.

Nodejs是基于Google Chrome Javascript运行时构建的平台。 Node.js与传统上在客户端应用程序中使用Javascript的用法不同。 Nodejs可以在客户端和服务器端应用程序中使用。 在本教程中,我们将研究如何将Nodejs安装到Linux发行版中,例如Ubuntu,Debian,Fedora,CentOS,RedHat。

使用Yum Package Manager安装Nodejs (Install Nodejs Using Yum Package Manager)

We can use yum package manager in order to install Nodejs. We will run the following command in order to install for Fedora, CentOS, RedHat.

我们可以使用yum软件包管理器来安装Nodejs。 为了安装Fedora,CentOS,RedHat,我们将运行以下命令。

$ yum install nodejs
Install Using Yum Package Manager
Install Using Yum Package Manager
使用Yum软件包管理器进行安装

使用Apt软件包管理器安装Nodejs(Install Nodejs Using Apt Package Manager)

We can use apt or apt-get package manager in order to install Nodejs. This will work Ubuntu and Debian based distributions too.

我们可以使用aptapt-get软件包管理器来安装Nodejs。 这也将适用于基于Ubuntu和Debian的发行版。

$ apt install nodejs

从二进制文件安装Node.js (Install Nodejs From Binaries)

If we need up to date binaries about Nodejs we can download from the official site. There are two versions to download Nodejs. Lower version is recommended for most of the users which is currently 6.11.0 LTS. LTS means long term support which means this version will be supported for a long time and will not create compatibility problems. 8.1.3 version will change during time. This version will have the latest features but it is not stable for production use.

如果我们需要有关Nodejs的最新二进制文件,可以从官方网站下载。 有两个版本可以下载Nodejs。 对于大多数用户,建议使用较低版本,当前版本为6.11.0 LTS。 LTS意味着长期支持,这意味着该版本将得到长期支持,不会造成兼容性问题。 8.1.3版本会随时更改。 此版本将具有最新功能,但在生产中不稳定。

Install Nodejs From Binaries
从二进制文件安装Node.js

下载Nodejs Binary (Download Nodejs Binary)

Simply download from following link.

只需从以下链接下载。

https://nodejs.org/en/download/

https://nodejs.org/en/download/

提取Node.js二进制文件 (Extract Nodejs Binary)

and then extract downloaded file with the xz command like below.

然后使用xz命令提取下载的文件,如下所示。

$ tar xvf node-v6.11.0-linux-x64.tar.xz

更新路径环境变量 (Update Path Environment Variable)

In order to access node binary from the shell we need to add the bin folder of the extracted folder to the PATH variable like below.

为了从外壳访问node二进制文件,我们需要将提取的文件夹的bin文件夹添加到PATH变量中,如下所示。

$ export PATH=$PATH:"/home/ismail/node-v6.11.0-linux-x64/bin"

We can test the Nodejs just typing following command.

我们只需键入以下命令即可测试Nodejs。

$ node
LEARN MORE  How To Install Gulp with Npm
了解更多如何使用Npm安装Gulp

翻译自: https://www.poftut.com/install-nodejs-ubuntu-debian-fedora-centos-redhat/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值