Ghost 0.4 and Amazon AMI sqlite3 Issue - Resolved

I thought I’d share an issue I experienced when upgrading Ghost to 0.4 and what I did to resolve it.

I wanted to upgrade Ghost to the latest version, 0.4 but first thought I would upgrade everything else. I did a yum update on my EC2 server to get all my packages up-to-date. I then upgraded Node.js to the latest stable version, as well as npm and all global packages (I install Node.js via source and did a npm update -g for all the other packages).

I then updated Ghost according to the docs initially here but prefer the documentation here instead. They’re basically the same but the second one looks cleaner.

When I did the npm install --production from my Ghost folder, I got some errors associated with sqlite3. The errors looked like this:

npm ERR! sqlite3@2.1.19 install: `node build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sqlite3@2.1.19 install script.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build.js
npm ERR! You can get their info via:
npm ERR!     npm owner ls sqlite3
npm ERR! There is likely additional logging output above.

There was some system info logged to the console and the npm-debug.log that I have left out but the above info is the essence of the error. At this point I realized my yum update command updated sqlite3 to the latest version from Amazon, likely wiping out anything related to Node’s sqlite. Whoops.

I then realized I needed to rebuild sqlite3 from source using NPM in an effort to get the correct version working with Ghost.

I first ensured I had the sqlite-devel package installed on my system and then ran the command: npm install -g node-gyp and npm install sqlite3 --build-from-source in order to rebuild sqlite3 from source.

After all that was done I was able to successfully run npm install --production and restart Ghost, which is using 0.4.