Strapi-connector-bookshelf breaking change?

System Information
  • Strapi Version: 3.2.4
  • Operating System: macOS High Sierra 10.13.6
  • Database: SQLite 5.0.0, PostgreSQL 8.4.1
  • Node Version: 12.18.4
  • NPM Version: >=6.0.0
  • Yarn Version: 1.22.4
  • strapi-connector-bookshelf in package.json: ^3.2.4


I added a new field to my model, got it working locally with no issues, and deployed it as per usual on Heroku. The build succeeded but the server crashed. Got the following error:

TypeError: Cannot read property 'register' of undefined

The error seems to be coming from a file index.js that doesn’t exist in my migrations folder - /app/node_modules/strapi-connector-bookshelf/lib/migrations/index.js:6:24

Here’s the detailed error logs from Heroku logs:

2021-06-16T09:14:59.182725+00:00 app[web.1]: [2021-06-16T09:14:59.182Z] debug ⛔️ Server wasn't able to start properly.
2021-06-16T09:14:59.183492+00:00 app[web.1]: [2021-06-16T09:14:59.183Z] error TypeError: Cannot read property 'register' of undefined
2021-06-16T09:14:59.183494+00:00 app[web.1]:     at module.exports (/app/node_modules/strapi-connector-bookshelf/lib/migrations/index.js:6:24)
2021-06-16T09:14:59.183494+00:00 app[web.1]:     at Object.initialize (/app/node_modules/strapi-connector-bookshelf/lib/index.js:47:5)
2021-06-16T09:14:59.183495+00:00 app[web.1]:     at Object.initialize (/app/node_modules/strapi-database/lib/connector-registry.js:30:25)
2021-06-16T09:14:59.183495+00:00 app[web.1]:     at DatabaseManager.initialize (/app/node_modules/strapi-database/lib/database-manager.js:36:27)
2021-06-16T09:14:59.183496+00:00 app[web.1]:     at Strapi.load (/app/node_modules/strapi/lib/Strapi.js:311:19)
2021-06-16T09:14:59.183496+00:00 app[web.1]:     at async Strapi.start (/app/node_modules/strapi/lib/Strapi.js:190:9)
2021-06-16T09:14:59.238779+00:00 heroku[web.1]: Process exited with status 1
2021-06-16T09:14:59.306810+00:00 heroku[web.1]: State changed from starting to crashed

What I tried:

I deleted the new field for the content-type and tried to deploy strapi again. Same server crash issue. So it’s not the new field that’s causing the rror.

I deleted my cache, build, package-lock.json, and node_modules folder. Did a fresh install npm install. Now the server crash error is happening locally running npm run develop. Here’s the error message:

error TypeError: Cannot read property 'register' of undefined
    at module.exports (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi-connector-bookshelf/lib/migrations/index.js:6:24)
    at Object.initialize (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi-connector-bookshelf/lib/index.js:47:5)
    at Object.initialize (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi-database/lib/connector-registry.js:30:25)
    at DatabaseManager.initialize (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi-database/lib/database-manager.js:36:27)
    at Strapi.load (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi/lib/Strapi.js:311:19)
    at async Strapi.start (/Users/jasonleow/Apps/strapi-lifelog/node_modules/strapi/lib/Strapi.js:190:9)
npm ERR! errno 1
npm ERR! strapi-lifelog@0.1.0 develop: `strapi develop`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the strapi-lifelog@0.1.0 develop script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jasonleow/.npm/_logs/2021-06-16T22_57_33_484Z-debug.log

What seems to the the cause:

The undefined variable from the error is strapi.db.migrations from the file in strapi-connector-bookshelf node_module node_modules/strapi-connector-bookshelf/lib/migrations/index.js:6:24. Here’s the code:

const draftAndPublish = require('./draft-publish');

module.exports = () => {

Advice needed:

Has anyone experienced this before? What might be some general steps to try to debug this?

Hoping for some broad pointers that I can research more on my own. Thank you!

Sounds like you have an outdated package, the register function is located in strapi-database:

1 Like

@jasonleow how did you resolve this issue? I have a similar one and any help is appreciated.