Andre Pan

The world is a result of surreal imagination

Read this first

在 CentOS 7 上用包管理器安装 Node.js

nodejs-new-pantone-black.png

 在 CentOS 上安装 Node.js 环境有多种手段,这里只涉及包管理器(也就是 Package Manager)安装的方法,其实很简单啦。

 1. 安装 EPEL

安装过程中会动态请求 EPEL (Extra Packages for Enterprise Linux) 库中的一些资源

$ sudo yum install epel-release


 2. 安装 Node

$ cd /tmp
$ curl — silent — location https://rpm.nodesource.com/setup_9.x | sudo bash -

安装过程中会如果提示检测到你有旧版本的 Node,可以通过

$ sudo yum remove -y nodejs npm

来删除旧版本,然后运行

$ sudo yum install -y nodejs

来安装 Node,安装时也会自动安装 npm(Node Package Manager)


 3. 升级 Node

安装完 Node 后确认一下是否安装完成

$ node -v

有可能会发现返回的是很老的版本号,并不是预想的新版,可以先装 Node 版本管理器 n

$ npm install -g n

然后通过 n 来升级,实际上就是安装新版本,选一个命令执行就可以了

$ n stable (安装最新的稳定版)
$ n latest (安装最新版本)
$ n lts (安装长期支持版本,一般会 LTS 版)
$ n (显示已安装版本并选择)

到此 Node 就安装完成了


 4. $ node -v 返回的版本号还是不对怎么办?

因为 yum 安装的 rpm 源的关系,可能是老版本的,而且默认安装在 /usr/local/bin 下面,和 n 安装的新版路径不一样,需要到 /etc/profile 里面添加新版本 Node 路径为系统路径,比如我想用8.9.4版本

$ n bin 8.9.4
...

Continue reading →


This looks pretty interesting, let’s see what will happen :)

It has been a very long time before SVBTLE finally opened to everyone, I even had forgotten its existence, until someone mentioned.

I wrote a shabby blog application for dumping my own mumble jumble 5 years ago, but due to lack of maintenance in code repository, it’s easily been attacked and spammed, but I DO NOT have time to fix those obvious but irrelevant bugs, so I just created a cronjob on server to rollback the spammed database table (usually Comment) automatically every week, which seems ridiculously weird, but that’s fine for lazy & busy guy like me. Well, I have to admit that thousands of spam comments on single page really helped me to optimized the code efficiency a lot back to the time of coding.

SVBTLE is pretty simple to use, more private feeling than Medium (so far), it looks like an online Write Room to me. By this moment, I found some interesting topics on my Magazine...

Continue reading →