惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Scott Helme
Scott Helme
P
Proofpoint News Feed
D
Docker
The Hacker News
The Hacker News
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Project Zero
Project Zero
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
GbyAI
GbyAI
Jina AI
Jina AI
P
Proofpoint News Feed
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
博客园 - 叶小钗
U
Unit 42
博客园_首页
Apple Machine Learning Research
Apple Machine Learning Research
Latest news
Latest news
T
The Exploit Database - CXSecurity.com
博客园 - 三生石上(FineUI控件)
博客园 - 聂微东
T
Threatpost
V
Vulnerabilities – Threatpost
C
Cisco Blogs
Spread Privacy
Spread Privacy
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
V
Visual Studio Blog
G
GRAHAM CLULEY
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - Franky
G
Google Developers Blog
Know Your Adversary
Know Your Adversary
F
Fortinet All Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
NISL@THU
NISL@THU
N
Netflix TechBlog - Medium
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Recent Announcements
Recent Announcements
量子位
S
Schneier on Security
I
Intezer
酷 壳 – CoolShell
酷 壳 – CoolShell
D
Darknet – Hacking Tools, Hacker News & Cyber Security

博客园 - 光脚码农

CentOS安装JDK CentOS 7中安装和配置Promethues - 光脚码农 - 博客园 查看和指定SpringBoot内嵌Tomcat的版本 - 光脚码农 - 博客园 CentOS中安装Azkaban 2.5 SpringBoot实用技巧札记 SQL实用札记【SQL Sever篇】 话说静态构造函数 如何利用正则表达式匹配花括号内的内容 如何为Windows Forms应用程序添加启动参数(Start-Up Parameters) 利用存储过程来重命名SQL Server数据库 .NET批量操作窗口样式 ViewData、ViewBag、TempData、Session的区别与联系 如何为自己的网页实现一个“回到顶部”的链接? 如何获得数据库中所有用户创建的索引 如何为一个类型为Color的属性设置默认值 用BCP从SQL Server 数据库中导出Excel文件 DataGridView如何绑定DataRow对象集合 Const vs. Readonly Windows下Git的安装与配置(Cygwin)
Centos7 安装Nodejs
光脚码农 · 2019-04-16 · via 博客园 - 光脚码农

使用EPEL安装

EPEL(Extra Packages for Enterprise Linux)企业版Linux的额外软件包,是Fedora小组维护的一个软件仓库项目,为RHEL/CentOS提供他们默认不提供的软件包。
先确认系统是否已经安装了epel-release包:

yum info epel-release

如果有输出有关epel-release的已安装信息,则说明已经安装,如果提示没有安装或可安装,则安装

sudo yum install epel-release

安装完后,就可以使用yum命令安装nodejs了,安装的一般会是较新的版本,并且会将npm作为依赖包一起安装

sudo yum install nodejs

安装完成后,验证是否正确的安装,node -v,如果输出如下版本信息,说明成功安装

v6.9.4

使用官方编译过的二进制数据包安装

进入官网的下载链接,在列表中进入想要下载的版本链接,选择与下面链接类似的想要下载的版本(*-linux-x64.tar.gz),右击并复制下载链接。进入用户主目录,使用wget命令下载,把下载路径粘贴到命令后

$ wget https://nodejs.org/download/release/latest-v6.x/node-v6.10.0-linux-x64.tar.gz

下载完成后使用下面的命令解压到/usr/local目录并安装:

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

安装完成后,验证是否正确的安装,node -v,如果输出如下版本信息,说明成功安装

v6.10.0

源码安装Nodejs

使用源码安装和二进制数据包安装的区别在于,源码安装还需要把源码编译,然后才能安装
下载源码的方式与上面的方法类似,进入官网下载页面,选择想要下载的版本(node-v*.tar.gz),获取到下载链接(与下面的链接类似),进入用户目录,把源码包下载下来:

$ wget https://nodejs.org/download/release/latest-v6.x/node-v6.10.0.tar.gz

下载完后,解压并进入解压后的目录

$ tar xzvf node-v* && cd node-v*

要编译源码需要安装 gccgcc-c++,可以先使用yum info package_name检查是否已经安装了这两个软件包,如果没有,则进行安装

$ sudo yum install gcc gcc-c++

安装后,运行configure文件并编译

./configure
make

编译的时间会比较长,如果不出意外,通常在20来分钟左右,所以要耐心的等待编译完成。编译完成后,使用下面命令安装

$ sudo make install

安装完成后,验证是否正确的安装,node -v,如果输出如下版本信息,说明成功安装

v6.10.0

当然还可以选择,使用nvm(node version manage)进行安装并管理node版本,但它默认是安装在用户目录下面,要全局安装,使所有用户都能使用同一node,则需要另外再做处理的。
就这三种方法而言,EPEL方式显然会比较轻松简单,一般用这种方式就好,如果想折腾下源码安装,也不复杂。

NodeJS常见异常

npm 安装express npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE

npm安装express或编译项目时出现:

npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! errno UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm ERR! request to https://registry.npmjs.org/express failed, reason: unable to verify the first certificate

解决方法:
设置下npm config set strict-ssl false就可以了

参考资料