serverless failed to add package "pg" (postgres) in build

Viewed 433

I am working with lambda implementation using serverless and using TypeOrm + Postgres as a Database interaction layer, Everything work perfectly in the local environment.

Issue : While I am deploying my lambda function using "serverless deploy", It will not add or ignoring dependency "pg". When I'm running lambda getting the following error. I using serverless.yml to configure.

2020-10-14T07:58:56.144Z 4faab731-d745-485c-8f2a-5e6de78331d7 ERROR DriverPackageNotInstalledError: Postgres package has not been found installed. Try to install it: npm install pg --save at new DriverPackageNotInstalledError (/var/task/node_modules/typeorm/error/DriverPackageNotInstalledError.js:10:28) at PostgresDriver.loadDependencies (/var/task/node_modules/typeorm/driver/postgres/PostgresDriver.js:967:19) at new PostgresDriver (/var/task/node_modules/typeorm/driver/postgres/PostgresDriver.js:203:14) at DriverFactory.create (/var/task/node_modules/typeorm/driver/DriverFactory.js:35:24) at new Connection (/var/task/node_modules/typeorm/connection/Connection.js:53:59) at ConnectionManager.create (/var/task/node_modules/typeorm/connection/ConnectionManager.js:56:26) at DatabaseGateway. (/var/task/DatabaseGateway.js:68:52) at Generator.next () at /var/task/DatabaseGateway.js:33:71 at new Promise ()

I have tried and checked :

  • "pg" is available in package.json (not in dev dependency)
  • tried by deleting dist and package-lock.json
  • also added dependency (inside serverless.yml) forcefully using
custom:
webpackIncludeModules:
forceInclude:
- pg

Thanks.

0 Answers
Related