首页  >  文章  >  web前端  >  nodejs中安装ghost出错解决办法

nodejs中安装ghost出错解决办法

小云云
小云云原创
2018-01-04 09:35:171187浏览

本文主要介绍了nodejs中安装ghost出错的原因及解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。

看了标题就知道安装ghost会碰到不少的坑,这里先说一个:

错误

(windows)通过ghost-cli来安装的步骤:


npm install -g ghost-cli  #全局安装ghost-cli
cd myghostblog   #进入工作目录
ghost install local #使用local参数在当前目录初始化一个ghost,使用sqlite数据库

出错信息如下:


√ Downloading and installing Ghost v?
√ Finishing install process
√ Configuring Ghost
√ Setting up instance
× Running database migrations
A SystemError occurred.

在ghost install local过程中不仅完成了ghost的初始化,还完成了依赖库的安装(也就是npm install)

从错误提示中看到Running database migrations出错了,其原因是:在下载依赖包sqlite3时出错,导致问题出现。

实际上在下载依赖包时出错,仅仅给出一个警告,警告都会跳过去,直到migrator这一步(数据迁移,也就是初始化数据库)出现了错误,导致安装失败。

而为什么下载sqlite3时出错了呢?

原因

就是因为sqlite3的包(sqlite3 for node)在.s3.amazonaws.com上,这个被墙了。*(满眼的泪呀!)

知道了原因,要解决就很容易了。

解决

解决方案是: cnpm install sqlite3 #使用taobao镜像安装

具体的过程如下:


npm install -g ghost-cli
cd myghostblog     
ghost install local   #会出错
cd current
cnpm install      #补装依赖库,并使用taobao镜像安装
knex-migrator init   #初始化sqlite数据库,会使用MigratorConfig.js
grunt dev      #运行 Dev 环境

打开浏览器http://localhost:2368/

加强

上面是在current目录下使用grunt运行起来的,如果要回到ghost-cli通过ghost来运行的话,还需要做一件事,将myghostblog\current\content\data\ghost-dev.db文件拷贝到myghostblog\content\data\ghost-dev.db,并修改文件名为ghost-local.db。(注意看目录差别,中间有一个current目录的差别)

这样就可以回到myghostblog目录使用ghost start来启动了。


cd myghostblog
ghost start

打开浏览器http://localhost:2368/

最后再说一下环境


windows 10
  Node Version: v6.10.3
  Ghost-CLI Version: 1.1.3
  Ghost Version: 1.14.0
2017-10-23

相关推荐:

深入解析ghost win8系统Hosts文件失效问题

将 Ghost 从 SQLite3 数据库迁移到 MySQL 数据库_MySQL

ghostwu 简单易懂的javascript变量提升

以上是nodejs中安装ghost出错解决办法的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn