-
Notifications
You must be signed in to change notification settings - Fork 417
Description
Hi,
I'm using knex and bookshelf with pg-library, the problem is that the pg library does not get bundled in to node_modules directory because it is not required in the files that get bundled (but is required by knex on runtime). This causes AWS Lambda to throw following errors.
2017-09-08T07:28:40.829Z 52dbac4f-9467-11e7-af3a-fdbf9a737897 Knex: run
$ npm install pg --save
Error: Cannot find module 'pg'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Client_PG._driver (/var/task/node_modules/knex/lib/dialects/postgres/index.js:91:12)
at Client_PG.initializeDriver (/var/task/node_modules/knex/lib/client.js:219:26)
at Client_PG.Client (/var/task/node_modules/knex/lib/client.js:113:10)
at new Client_PG (/var/task/node_modules/knex/lib/dialects/postgres/index.js:56:20)
at Knex (/var/task/node_modules/knex/lib/index.js:60:34)
at Object.module.exports.dev.elasticsearch (/var/task/index.js:102:35)
at webpack_require (/var/task/index.js:20:30)
at Object. (/var/task/index.js:79:17)
at webpack_require (/var/task/index.js:20:30)
at Object. (/var/task/index.js:270:12)
at webpack_require (/var/task/index.js:20:30)
at Object. (/var/task/index.js:217:15)
Probably the cause is that this is not direct depency but resolved one during runtime which is then not resolved by webpack during bundling. I would appreciate a lot if this could work, although i could also probably just:
var dump = require("pg");
in order to get it bundled for now