沖和斋

终于升级Node.js到V4.6.0

前几天升级Node版本失败后一直心有不甘,强迫症犯了一样,反复升级了很多次,但都以失败告终。幸好学会了降级的方法,每次都能够起死回生。
今天终于升级成功,从V0.10.47升级到了V4.6.0,记录升级过程如下:

1、检查Node版本
node -v

2、检查Node安装位置
which node

PS:如果地址是/usr/bin/node,则不用管;如果是/usr/local/bin/node,需要替换配置。

3、删除当前的Node.js
apt-get purge nodejs

4、获取Node V4版本源码
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -

5、更新apt-get
apt-get update

PS:第4步可能会自动执行此命令,如是,则忽略此步

6、升级当前安装包(可选)
apt-get upgrade

7、安装Node.js
apt-get install nodejs

8、进入Ghost安装文件夹
cd /var/www/

9、停止Ghost
forever stop index.js

10、删除Node_modules文件夹
rm -rf node_modules

11、重新安装Node模块
npm install --production

12、设置权限
chown -R ghost:ghost ./*

13、启动Ghost
NODE_ENV=production forever start index.js

—EOF—