Problem with knex-migrator

I have a problem with migration from 2.22 to 2.23.2 and knex-migrator 3.3 on node.js v10.13:

lib/node_modules/knex-migrator/bin/knex-migrator-migra
te:9
utils.getKnexMigrator({path: process.cwd()})
^

TypeError: utils.getKnexMigrator is not a function
at Object. (/home/peleke7/lib/node_modules/knex-migra
tor/bin/knex-migrator-migrate:9:7)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js
:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:1
2)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

Hi @Peleke! How exactly are you running into this problem? Are you using ghost-cli to update your blog instance? At what point is this error happening? Could you please provide a more reproducible scenario to get this error? Cheers!

Yes, sure. I am running Ghost self-hosted and I am using this script to update it: Ghost 3 auf Uberspace 7 per Script aktualisieren | Pelekes Blog
I didn’t change anything to the script for a while and it worked as it should for a lot of updates already.
Could it be an issue of the new knex-migrator 3.3 that I have updated before the Ghost update? This version is not yet listed on GitHub but available already on npm.

Could it be an issue of the new knex-migrator 3.3

This is interesting. Could you check if it works with an earlier version of knex-migrator?

I just applied the same procedure as the last time but with knex-migrator 3.2.6 instead of 3.3.0 to update ghost from 2.23.2 to 2.23.3 and it worked as it should. So it seems to be an issue with knex-migrator 3.3.0

This is an interesting lead. I will try to have a closer look at it on Monday. Would really appreciate if you could be able to track it down to some more specific point :raised_hands: The tests are still passing on the latest version, but now I’m a bit dubious about bumping the version in Ghost core :thinking:

Is the above error message not helpful? Is there a way to turn on verbose or debug mode?

Hey @Peleke! Version 3.3.1 of knex-migrator has been released. Let me know if everything works as expected now :wink:

Hi @naz, I just updated Ghost from 2.23.3 -> 2.23.4 with knex-migrator 3.3.1 and now it shows a different error:

ERROR Cannot find module '../migrations'

Cannot find module '../migrations'

Error Code: 
    MODULE_NOT_FOUND

----------------------------------------

Error: Cannot find module '../migrations'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/home/peleke7/lib/node_modules/knex-migrator/lib/index.js:9:20)
    at Module._compile (internal/modules/cjs/loader.js:688:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
    at Module.load (internal/modules/cjs/loader.js:598:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
    at Function.Module._load (internal/modules/cjs/loader.js:529:3)
    at Module.require (internal/modules/cjs/loader.js:636:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at /home/peleke7/lib/node_modules/knex-migrator/lib/utils.js:162:20
    at tryCatcher (/home/peleke7/lib/node_modules/knex-migrator/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/peleke7/lib/node_modules/knex-migrator/node_modules/bluebird/js/release/promise.js:517:31)
    at Promise._settlePromise (/home/peleke7/lib/node_modules/knex-migrator/node_modules/bluebird/js/release/promise.js:574:18)

It seems that it is still not solved. Should I open a new ticket or do you want to re-open the existing one?

No need to reopen the issue, the fix is too trivial. I will reference the closed one and release a new minor in a bit :+1: Tested the package locally with yarn link and now I know one of the downsides of this approach :slight_smile:

Released 3.3.2 :tada:

Thanks, that works as it should again, problem solved. :grinning:

One question about updating knex-migrator:

Should I use

npm install -g knex-migrator

or

npm update -g knex-migrator

After reading node.js - npm install vs. update - what's the difference? - Stack Overflow I wasn’t sure which method is better in this case (or if it matters at all).

Think when using in global context -g it’s safest using npm install because of this reason:

set them as global (which puts them in the shell’s PATH)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.