Error when loading extension jsreport-contrib-mongodb
-
Hey everyone,
I'm having an issue setting up mongodb extention, I have installed the extention
npm install mongodb --save && npm install jsreport-contrib-mongodb
once I attempt to start the server with
jsreport start
2018-07-20T14:15:39.240Z - info: Using extension chrome-pdf 2018-07-20T14:15:39.298Z - info: Using extension html-to-xlsx 2018-07-20T14:15:39.372Z - info: html-to-xlsx detected chrome as available html engine 2018-07-20T14:15:39.372Z - info: Using extension studio 2018-07-20T14:15:39.394Z - info: Using extension version-control 2018-07-20T14:15:39.416Z - info: Using extension licensing 2018-07-20T14:15:39.431Z - info: Using extension data 2018-07-20T14:15:39.433Z - info: Using extension pdf-utils 2018-07-20T14:15:39.633Z - info: Using extension text 2018-07-20T14:15:39.634Z - info: Using extension reports 2018-07-20T14:15:39.638Z - info: Using extension base 2018-07-20T14:15:39.642Z - info: Using extension browser-client 2018-07-20T14:15:39.660Z - info: Using extension fs-store 2018-07-20T14:15:39.813Z - info: Using extension scheduling 2018-07-20T14:15:39.859Z - info: Using extension scripts 2018-07-20T14:15:39.864Z - info: Using extension assets 2018-07-20T14:15:39.870Z - info: Using extension xlsx 2018-07-20T14:15:39.894Z - info: Using extension sample-template 2018-07-20T14:15:39.896Z - info: Using extension resources 2018-07-20T14:15:39.897Z - info: Using extension public-templates 2018-07-20T14:15:39.900Z - debug: Extension public-templates was disabled 2018-07-20T14:15:39.900Z - info: Using extension jsreport-contrib-mongodb 2018-07-20T14:15:39.901Z - error: Error when loading extension jsreport-contrib-mongodb TypeError: Cannot read property 'push' of undefined at Object.module.exports (/home/linux/jsreportapp/node_modules/jsreport-contrib-mongodb/lib/mongo.js:3:44) at Object._useOne (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:174:75) at Object._useMany (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:87:20) at process._tickCallback (internal/process/next_tick.js:68:7) 2018-07-20T14:15:39.902Z - error: Error occured during reporter init Error: Error when loading extension jsreport-contrib-mongodb TypeError: Cannot read property 'push' of undefined at Object.module.exports (/home/linux/jsreportapp/node_modules/jsreport-contrib-mongodb/lib/mongo.js:3:44) at Object._useOne (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:174:75) at Object._useMany (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:87:20) at process._tickCallback (internal/process/next_tick.js:68:7) at Object._useOne (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:183:15) at Object._useMany (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:87:20) at process._tickCallback (internal/process/next_tick.js:68:7) An error has occurred when trying to initialize jsreport (2). Error when loading extension jsreport-contrib-mongodb TypeError: Cannot read property 'push' of undefined at Object.module.exports (/home/linux/jsreportapp/node_modules/jsreport-contrib-mongodb/lib/mongo.js:3:44) at Object._useOne (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:174:75) at Object._useMany (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:87:20) at process._tickCallback (internal/process/next_tick.js:68:7) (1). caused by error (2) -> stack = Error: at instance.init.then.catch (/home/linux/jsreportapp/node_modules/jsreport-cli/lib/instanceHandler.js:31:29) at process._tickCallback (internal/process/next_tick.js:68:7) caused by error (1) -> stack = Error: at Object._useOne (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:183:15) at Object._useMany (/home/linux/jsreportapp/node_modules/jsreport-core/lib/extensions/extensionsManager.js:87:20) at process._tickCallback (internal/process/next_tick.js:68:7)
Here is the content of
/home/linux/jsreportapp/node_modules/jsreport-contrib-mongodb/lib/mongo.js
module.exports = function (reporter, definition) { if (reporter['scripts'].allowedModules !== '*') { reporter['scripts'].allowedModules.push({ id : 'mongodb', path: require.resolve('mongodb') }); } };
-
Hi, the
jsreport-contrib-mongodb
is now deprecated.Instead just install mongo client using
npm install mongodb --save
And allow using external modules in jsreport. This handy shortcut will allow all modules and also access to the file system.
{ "httpPort": 5488, ... "allowLocalFileAcess": true ... }
-
Thanks @jan_blaha I have removed
jsreport-contrib-mongodb
package and followed the guide you provided and I'm able to retrieve data from MongodDB.