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
使用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.
我们可以使用apt
或apt-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版本会随时更改。 此版本将具有最新功能,但在生产中不稳定。
下载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
翻译自: https://www.poftut.com/install-nodejs-ubuntu-debian-fedora-centos-redhat/