Ghost update troubleshooting

Ghost upgrade might went wrong sometimes.

This particular error I encountered is a "502 Bad Gateway" page after upgrade ghost from 0.7.9 to 0.8.0.

The first issue is on npm install gives me npm WARN cannot run in wd [email protected] npm install semver && node -e "require('./core/server/utils/startup-check.js').nodeVersion()" (wd=/var/www/ghost).

This is permission issue that it doesn't let you run as root user. While it's not ideal to run as root, but if you insist, then use npm install --production --unsafe-perm.

Remember to chown -R ghost:ghost on node_modules directory after npm install.

Then it still wouldn't fix the 502 Bad Gateway issue.

I digged deeper with node index.js and it gives me the following:

Knex: run
$ npm install sqlite3 --save
Error: Cannot find module '/var/www/ghost/node_modules/sqlite3/lib/binding/node-v46-linux-x64/node_sqlite3.node'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/var/www/ghost/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Client._driver (/var/www/ghost/node_modules/knex/lib/dialects/sqlite3/index.js:37:12)
    at Client.initializeDriver (/var/www/ghost/node_modules/knex/lib/client.js:162:26)
    at Client (/var/www/ghost/node_modules/knex/lib/client.js:41:10)
    at Client_SQLite3 (/var/www/ghost/node_modules/knex/lib/dialects/sqlite3/index.js:23:10)
    at new Client (/var/www/ghost/node_modules/knex/lib/util/make-client.js:15:18)
    at Knex (/var/www/ghost/node_modules/knex/lib/index.js:26:19)
    at Object.<anonymous> (/var/www/ghost/core/server/data/db/connection.js:33:20)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.get [as knex] (/var/www/ghost/core/server/data/db/index.js:7:36)
    at Object.<anonymous> (/var/www/ghost/core/server/models/base/index.js:28:30)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)

Seems like Sqlite3 is acting up. Now we need to build it manually.

First, let's get the necessary tools.

apt-get install build-essential make

Then we run the following command.

npm install sqlite3 --build-from-source

Run node index.js again and it works out well.

See more at https://github.com/jewei/GhostUtils/blob/master/Troubleshooting.md.

Ghost update troubleshooting
Share this