Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't add bootshelf plugin #7339

Closed
francescofact opened this issue Aug 5, 2020 · 4 comments
Closed

Can't add bootshelf plugin #7339

francescofact opened this issue Aug 5, 2020 · 4 comments
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug source: docs Documentation changes status: confirmed Confirmed by a Strapi Team member or multiple community members

Comments

@francescofact
Copy link

Hi, i'm trying to add a plugin to my bookshelf.
i installed the plugin with
npm install --save bookshelf-simplepaginate
then i created the file in config/functions/bookshelf.js
with:

'use strict';

module.exports = (bookshelf, connection) => {
  bookshelf.plugin(require('bookshelf-simplepaginate'));
};

But strapi goes in bootloop saying:

0|Strapi  | [2020-08-05T15:54:33.294Z] debug ⛔️ Server wasn't able to start properly.
0|Strapi  | [2020-08-05T15:54:33.301Z] error TypeError: require(...) is not a function
0|Strapi  |     at Object.keys.filter.map.connectionName (/home/pi/strapi/node_modules/strapi-connector-bookshelf/lib/index.js:62:36)
0|Strapi  |     at Array.map (<anonymous>)
0|Strapi  |     at Object.initialize (/home/pi/strapi/node_modules/strapi-connector-bookshelf/lib/index.js:46:8)
0|Strapi  |     at Object.initialize (/home/pi/strapi/node_modules/strapi-database/lib/connector-registry.js:30:25)
0|Strapi  |     at DatabaseManager.initialize (/home/pi/strapi/node_modules/strapi-database/lib/database-manager.js:36:27)
0|Strapi  |     at Strapi.load (/home/pi/strapi/node_modules/strapi/lib/Strapi.js:297:19)

What am i doing wrong?

@derrickmehaffy
Copy link
Member

@alexandrebodin @lauriejim do you have any suggestions here?

@alexandrebodin
Copy link
Member

alexandrebodin commented Aug 6, 2020

bookshelf.plugin must be called with a string not a required module :) try bookshelf.plugin('bookshelf-simplepaginate')

@derrickmehaffy
Copy link
Member

bookshelf.plugin must be called with a string not a required module :) try bookshelf.plugin('bookshelf-simplepaginate')

Ah so our documentation is wrong: https://strapi.io/documentation/v3.x/concepts/configurations.html#database-orm-customization

I'll submit a PR to fix this, @alexandrebodin can you confirm if they need to require this package anywhere or just adding the name of the plugin and installing it into their package.json is enough?

@alexandrebodin
Copy link
Member

it is enough yes

@lauriejim lauriejim added good first issue Good for newcomers source: docs Documentation changes status: confirmed Confirmed by a Strapi Team member or multiple community members issue: bug Issue reporting a bug labels Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers issue: bug Issue reporting a bug source: docs Documentation changes status: confirmed Confirmed by a Strapi Team member or multiple community members
Projects
None yet
Development

No branches or pull requests

4 participants