CentOS简单操作命令及node.js的安装方法

本文实例讲述了CentOS简单操作命令及node.js的安装方法。分享给大家供大家参考,具体如下:

查看centos内核的版本:

uname -a

uname -r

查看linux版本:

cat /etc/issue

查看系统是64位还是32位:

getconf LONG_BIT

安装node.js

因为node.js需要Python2.6以上

Note: Python 2.6 or 2.7 is required to build from source tarballs.

查看Python版本

python -V

安装依赖

yum -y install gcc make gcc-c++ openssl-devel wget

下载node.js源码及安装

wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz

tar -zxf node-v0.12.0.tar.gz

cd node-v0.12.0

./configure && make && make install

Ubuntu/Debian/CentOS系统安装Node.js软件教程

老蒋在”Ubuntu 18.04 LTS系统安装Node.js运行环境”文章中有分享到在Ubuntu环境中安装Node.js,且顺带一并安装NPM工具的教程。但是今天在给一个网友解决问题的时候,其需要在CentOS中安装Node.js,因为其默认的CentOS7版本Node.js低于5.0的,且某个软件是需要在高版本中运行。

所以,在这篇文章中,直接整理比较全的Ubuntu/Debian/CentOS系统,安装最新版本Node.js的教程,目前最新的版本是10.0,但是一般我们也不要太追求最新,我们可以安装8.0或者9.0差不多。

第一、Ubuntu

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
apt-get install -y nodejs

第二、Debian

curl -sL https://deb.nodesource.com/setup_9.x | bash -
apt-get install -y nodejs

第三、CentOS

curl -sL https://rpm.nodesource.com/setup_9.x | bash -
yum install nodejs -y

安装过程都是差不多的。

未分类

看到如图,然后会指示我们下面执行哪个命令。

未分类

我们可以看到最新版本Node.JS和npm。

CentOS 安装 node.js

centos 7 安装

  • centos 7 yum
yum install -y epel-release  
/usr/bin/yum install -y nodejs

centos 6安装

  • 由于yum源版本过低,cnpm安装失败,使用nvm管理node包的时候
yum remove nodejs -y  
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash  
  • 安装成功后:一定要重新启动shell
command -v nvm  
  • 查看nvm可安装版本
nvm ls-remote  
  • 安装nodejs
nvm install v6.12.3  

国内安装源

cnpm
/usr/bin/npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 配置文件 ~/.npmrc 文件中写入源地址
registry =https://registry.npm.taobao.org