centosyumnodejs的简单介绍

本文目录一览:

如何在CentOS 7服务器上安装NodeJS

Introduction

Node.js is a Javascript platform for server-side programming. It

allows users to easily create networked applications that require

backend functionality. By using Javascript as both the client and server

language, development can be fast and consistent.

In this guide, we will show you a few different ways of getting

Node.js installed on a CentOS 7 server so that you can get started. Most

users will want to use the EPEL installation instructions or the NVM

installation steps.

Install Node from Source

One way of acquiring Node.js is to obtain the source code and compile it yourself.

To do so, you should grab the source code from the project’s website.

On the downloads page, right click on the “Source Code” link and click

“Copy link address” or whatever similar option your browser gives you.

On your server, use wget and paste the link that you copied in order to download the archive file:

wget

Extract the archive and move into the new directory by typing:

tar xzvf node-v* cd node-v*

There are a few packages that we need to download from the CentOS

repositories in order to compile the code. Use yum to get these now:

sudo yum install gcc gcc-c++

Now, we can configure and compile the software:

./configure

make

The compilation will take quite awhile. When it is finished, you can install the software onto your system by typing:

sudo make install

To check that the installation was successful, you can ask Node to display its version number:

node –version

v0.10.30

If you see the version number, then the installation was completed successfully.

Install a Package from the Node Site

Another option for installing Node.js on your server is to simply get

the pre-built packages from the Node.js website and install them.

You can find the Linux binary packages here. Since CentOS 7 only

comes in the 64-bit architecture, right click on the link under “Linux

Binaries (.tar.gz)” labeled “64-bit”. Select “Copy link address” or

whatever similar option your browser provides.

On your server, change to your home directory and use the wget

utility to download the files. Paste the URL you just copied as the

argument for the command:

cd ~

wget

Note: Your version number in the URL is likely to be different than

the one above. Use the address you copied from the Node.js site rather

than the specific URL provided in this guide.

Next, we will extract the binary package into our system’s local

package hierarchy with the tar command. The archive is packaged within a

versioned directory, which we can get rid of by passing the

–strip-components 1 option. We will specify the target directory of our

command with the -C command:

sudo tar –strip-components 1 -xzvf node-v* -C /usr/local

This will install all of the components within the /usr/local branch of your system.

You can verify that the installation was successful by asking Node for its version number:

node –version

v0.10.30

The installation was successful and you can now begin using Node.js on your CentOS 7 server.

Install Node from the EPEL Repository

An alternative installation method uses the EPEL (Extra Packages for

Enterprise Linux) repository that is available for CentOS and related

distributions.

To gain access to the EPEL repo, you must modify the repo-list of

your installation. Fortunately, we can reconfigure access to this

repository by installing a package available in our current repos called

epel-release.

sudo yum install epel-release

Now that you have access to the EPEL repository, you can install Node.js using your regular yum commands:

sudo yum install nodejs

Once again, you can check that the installation was successful by asking Node to return its version number:

node –version

v0.10.30

Many people will also want access to npm to manage their Node packages. You can also get this from EPEL by typing:

sudo yum install npm

Install Node Using the Node Version Manager

Another way of installing Node.js that is particularly flexible is

through NVM, the Node version manager. This piece of software allows you

to install and maintain many different independent versions of Node.js,

and their associated Node packages, at the same time.

To install NVM on your CentOS 7 machine, visit the project’s GitHub

page. Copy the curl or wget command from the README file that displays

on the main page. This will point you towards the most recent version of

the installation script.

Before piping the command through to bash, it is always a good idea

to audit the script to make sure it isn’t doing anything you don’t agree

with. You can do that by removing the | bash segment at the end of the

curl command:

curl https//raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh

Take a look and make sure you are comfortable with the changes it is

making. When you are satisfied, run the command again with | bash

appended at the end. The URL you use will change depending on the latest

version of NVM, but as of right now, the script can be downloaded and

executed by typing:

curl | bash

This will install the nvm script to your user account. To use it, you must first source your .bash_profile:

source ~/.bash_profile

Now, you can ask NVM which versions of Node it knows about:

nvm list-remote

. . .

v0.10.29

v0.10.30

v0.11.0

v0.11.1

v0.11.2

v0.11.3

v0.11.4

v0.11.5

v0.11.6

v0.11.7

v0.11.8

v0.11.9

v0.11.10

v0.11.11

v0.11.12

v0.11.13

You can install a version of Node by typing any of the releases you see. For instance, to get version 0.10.30, you can type:

nvm install v0.10.30

You can see the different versions you have installed by typing:

nvm list

– v0.10.30

system

You can switch between them by typing:

nvm use v0.10.30

Now using node v0.10.30

To set this version as the default, type:

nvm alias default v0.10.30

default – v0.10.30

You can verify that the install was successful using the same technique from the other sections, by typing:

node –version

v0.10.30

From the version number output, we can tell that Node is installed on our machine as we expected.

Conclusion

As you can see, there are quite a few different ways of getting

Node.js up and running on your CentOS 7 server. If one of the

installation methods is giving you problems, try one of the other

options.

如何在centos下部署Node环境

你可以通过运行以下命令。 sudo yum install epel-release现在可以使用yum命令安装Node.js了。 sudo yum install nodejs因为在开发过程中我需要管理节点包,我还要安装新公共管理的软件包管理器,使用以下命令。 sudo yum install npm

node.js怎么安装node modules

1、首先,在CentOS上使用命令yum install nodejs可以直接安装,但是这样可能无法安装最新版本。

2、安装好之后,可以使用node -v命令和npm -v命令查看Node.js的版本和包管理器的版本。

3、接着可以使用yum uninstall nodejs卸载旧版本的nodejs。同时也会自动卸载npm。

4、接着,再次使用yum install命令安装nodejs,这时候安装的就是新版本了。

5、安装完毕后,使用npm -v查看包管理器版本,也是新版本。

6、如果只是要运行node.js,直接node回车即可。在里边输入javascript代码。

如何在CentOS / RHEL 7/6/5上安装最新的Nodejs和NPM

1、如果对nodejs环境有比较高的要求,建议选择源码安装的方式进行安装。

你可以到nodejs org官网上面找到相对的tar.gz文件包。

通过wget命令下载到centos服务器上, 然后进行源码安装。

2、如果对版本要求不高,可以直接用centos的包管理器yum进行安装

yum install nodejs npm

3、nodejs版本也可以通过nvm等工具去控制,期待深入研究。

学习Linux运维的知识,可以参考《Linux就该这么学》

原创文章,作者:小蓝,如若转载,请注明出处:https://www.506064.com/n/312804.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
小蓝小蓝
上一篇 2025-01-06 15:17
下一篇 2025-01-06 15:17

相关推荐

  • Python简单数学计算

    本文将从多个方面介绍Python的简单数学计算,包括基础运算符、函数、库以及实际应用场景。 一、基础运算符 Python提供了基础的算术运算符,包括加(+)、减(-)、乘(*)、除…

    编程 2025-04-29
  • Python满天星代码:让编程变得更加简单

    本文将从多个方面详细阐述Python满天星代码,为大家介绍它的优点以及如何在编程中使用。无论是刚刚接触编程还是资深程序员,都能从中获得一定的收获。 一、简介 Python满天星代码…

    编程 2025-04-29
  • Python海龟代码简单画图

    本文将介绍如何使用Python的海龟库进行简单画图,并提供相关示例代码。 一、基础用法 使用Python的海龟库,我们可以控制一个小海龟在窗口中移动,并利用它的“画笔”在窗口中绘制…

    编程 2025-04-29
  • Python樱花树代码简单

    本文将对Python樱花树代码进行详细的阐述和讲解,帮助读者更好地理解该代码的实现方法。 一、简介 樱花树是一种图形效果,它的实现方法比较简单。Python中可以通过turtle这…

    编程 2025-04-28
  • Python大神作品:让编程变得更加简单

    Python作为一种高级的解释性编程语言,一直被广泛地运用于各个领域,从Web开发、游戏开发到人工智能,Python都扮演着重要的角色。Python的代码简洁明了,易于阅读和维护,…

    编程 2025-04-28
  • 用Python实现简单爬虫程序

    在当今时代,互联网上的信息量是爆炸式增长的,其中很多信息可以被利用。对于数据分析、数据挖掘或者其他一些需要大量数据的任务,我们可以使用爬虫技术从各个网站获取需要的信息。而Pytho…

    编程 2025-04-28
  • 如何制作一个简单的换装游戏

    本文将从以下几个方面,为大家介绍如何制作一个简单的换装游戏: 1. 游戏需求和界面设计 2. 使用HTML、CSS和JavaScript开发游戏 3. 实现游戏的基本功能:拖拽交互…

    编程 2025-04-27
  • Guava Limiter——限流器的简单易用

    本文将从多个维度对Guava Limiter进行详细阐述,介绍其定义、使用方法、工作原理和案例应用等方面,并给出完整的代码示例,希望能够帮助读者更好地了解和使用该库。 一、定义 G…

    编程 2025-04-27
  • 2的32次方-1:一个看似简单却又复杂的数字

    对于计算机领域的人来说,2的32次方-1(也就是十进制下的4294967295)这个数字并不陌生。它经常被用来表示IPv4地址或者无符号32位整数的最大值。但实际上,这个数字却包含…

    编程 2025-04-27
  • 制作一个简单的管理系统的成本及实现

    想要制作一个简单的管理系统,需要进行技术选型、开发、测试等过程,那么这个过程会花费多少钱呢?我们将从多个方面来阐述制作一个简单的管理系统的成本及实现。 一、技术选型 当我们开始思考…

    编程 2025-04-27

发表回复

登录后才能评论