Cloud Function Cannot Connect To PostgreSQL With SequelizeJS In Production (Works Locally)

This code snippet works perfectly locally with netlify dev:

const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(process.env.DATABASE_URI); // postgres uri
sequelize.create({...});

However, when I deploy this to production, the function logs this error message:

{"errorType":"Error","errorMessage":"Please install pg package manually","stack":["Error: Please install pg package manually","    at ConnectionManager._loadDialectModule (/var/task/node_modules/sequelize/dist/lib/dialects/abstract/connection-manager.js:55:15)","...

I confirmed that all the node packages are installed before site deployment, including pg. Did anyone also encounter issue?

I have to add this line

require('pg')

on the top of the file for my production deployment to work. Not sure why this discrepancy exists between production and dev.