Ghost: Update to 0.10.1 fails when using Ghost as an npm module (TypeError: _.toPairs)

Issue Summary

2016-09-07T08:19:09.627945+00:00 app[web.1]: Migrations: Creating database backup
2016-09-07T08:19:09.687236+00:00 app[web.1]: 
2016-09-07T08:19:09.687239+00:00 app[web.1]: ERROR: undefined is not a function 
2016-09-07T08:19:09.687260+00:00 app[web.1]:     at getSettingsResult (/app/node_modules/ghost/core/server/api/settings.js:357:44)
2016-09-07T08:19:09.687281+00:00 app[web.1]:     at tryCatcher (/app/node_modules/ghost/node_modules/bluebird/js/release/util.js:16:23)
2016-09-07T08:19:09.687290+00:00 app[web.1]:     at Promise._settlePromise (/app/node_modules/ghost/node_modules/bluebird/js/release/promise.js:561:18)
2016-09-07T08:19:09.687290+00:00 app[web.1]:     at Promise._settlePromise0 (/app/node_modules/ghost/node_modules/bluebird/js/release/promise.js:606:10)
2016-09-07T08:19:09.687290+00:00 app[web.1]:     at Promise._settlePromises (/app/node_modules/ghost/node_modules/bluebird/js/release/promise.js:685:18)
2016-09-07T08:19:09.687291+00:00 app[web.1]:     at Async._drainQueue (/app/node_modules/ghost/node_modules/bluebird/js/release/async.js:138:16)
2016-09-07T08:19:09.756832+00:00 app[web.1]:     at Async._drainQueue (/app/node_modules/ghost/node_modules/bluebird/js/release/async.js:143:12)
2016-09-07T08:19:09.756834+00:00 app[web.1]:     at Immediate.Async.drainQueues (/app/node_modules/ghost/node_modules/bluebird/js/release/async.js:17:14)
2016-09-07T08:19:09.756837+00:00 app[web.1]:     at Immediate._onImmediate (/app/node_modules/@risingstack/trace/node_modules/continuation-local-storage/node_modules/async-listener/glue.js:188:31)
2016-09-07T08:19:09.757542+00:00 app[web.1]:     at Promise._settlePromise (/app/node_modules/ghost/node_modules/bluebird/js/release/promise.js:561:18)
2016-09-07T08:19:09.757542+00:00 app[web.1]:     at Promise._settlePromiseCtx (/app/node_modules/ghost/node_modules/bluebird/js/release/promise.js:598:10)
2016-09-07T08:19:09.757544+00:00 app[web.1]:     at Immediate.Async.drainQueues (/app/node_modules/ghost/node_modules/bluebird/js/release/async.js:17:14)

Steps to Reproduce

  1. Update to ghost@0.10.1

Technical details:

  • Ghost Version: 0.10.1
  • Node Version: 4.x
  • Browser/OS: Alpine
  • Database: Postgre

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 21 (19 by maintainers)

Commits related to this issue

Most upvoted comments

I’m having a very similar issue.

I’ve setup Ghost for my new blog. I use it as a NPM Module.

I recently updated the blog from 0.7 to 0.8 then 0.9 with no issue.

But when I updated Ghost to the latest version (0.10.1) I got an error error:

Unhandled rejection TypeError: _.toPairs is not a function
    at settingsFilter (/www/al-blog/node_modules/ghost/core/server/api/settings.js:112:35)
    at settingsResult (/www/al-blog/node_modules/ghost/core/server/api/settings.js:215:37)
    at /www/al-blog/node_modules/ghost/core/server/api/settings.js:361:28
    at tryCatcher (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromiseCtx (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/promise.js:598:10)
    at Async._drainQueue (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/async.js:143:12)
    at Async._drainQueues (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/www/al-blog/node_modules/ghost/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate [as _immediateCallback] (timers.js:383:17)
Ghost has shut down

Your blog is now offline
Migrations: Creating database backup
Migrations: Database backup written to: /www/al-blog/content/data/ghost.2016-09-07.json
Migrations: Migration required from 006 to 007
Migrations: No tasks found for version
Migrations: Updating database to 007
Migrations: Running fixture updates
Skipping Migrations: rolling back because of: undefined
Ghost is running in production…

Spec:

Ghost Version: 0.7.8 Node Version: v4.4.2 NPM Version: 3.8.5 Browser/OS: All Database: MySql

The correct workaround would be to require the overrides file inside of your version of the index.jsfile. I realise it is not ideal, but it should solve your problem without waiting for another release.

The Lodash function, _, isn’t frozen by default and using _.mixin shouldn’t help with that. The _.mixin method will make those others available for chaining though, e.g. _(obj).toPairs().map(...).value()

Hey there @gergelyke, I’m not sure what has happened for you here. We have successfully upgraded all of our production blogs on Ghost(Pro) so I’m 100% confident that the upgrade does work.

Without some more info about your specific environment, I’m not sure what to suggest other than to read through the upgrade troubleshooting guide, check everything over and if you’re still having trouble swing by the #help channel in our slack team.

Going to close this because, as I said I’m confident the upgrade works. Feel free to post back if you find something specific that does identify this as a bug rather than and environment / upgrade issue and I’ll reopen.