serverless-esbuild icon indicating copy to clipboard operation
serverless-esbuild copied to clipboard

Bug - Please install pg package manually after the deployment

Open akshay-scalex opened this issue 2 years ago • 2 comments

Describe the bug I am using postgresql as database and sequelize as ORM. When I run the code locally it works fine. But when deployed, it throws an error - Please install pg package manually.

Expected behavior When deployed the query should return the data from postgresql database.

Screenshots or Logs Screenshot 2023-05-23 at 5 16 15 PM

Versions (please complete the following information):

  • OS: Mac M1
  • Serverless Framework Version: [e.g. 3.0.0]
  • Plugin Version: 1.23.3

Additional context tsconfig.json file

{
  "extends": "./tsconfig.paths.json",
  "compilerOptions": {
    "lib": ["ESNext"],
    "moduleResolution": "node",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "removeComments": true,
    "sourceMap": true,
    "target": "ES2020",
    "outDir": "lib"
  },
  "include": ["src/**/*.ts", "serverless.ts"],
  "exclude": [
    ".serverless/**/*",
    ".webpack/**/*",
    "_warmup/**/*",
    ".vscode/**/*"
  ],
  "ts-node": {
    "require": ["tsconfig-paths/register"]
  }
}

serverless.ts file

import type { AWS } from "@serverless/typescript";

import helloWorld from "@functions/hello_world";


const serverlessConfiguration: AWS = {
    service: "hello-world-service",
    frameworkVersion: "3",
    plugins: [
        "serverless-esbuild",
        "serverless-offline",
        "serverless-dotenv-plugin",
    ],
    useDotenv: true,
    provider: {
        name: "aws",
        runtime: "nodejs14.x",
        timeout: 10,
        apiGateway: {
            minimumCompressionSize: 1024,
            shouldStartNameWithService: true,
        },
        environment: {
            AWS_NODEJS_CONNECTION_REUSE_ENABLED: "1",
            NODE_OPTIONS: "--enable-source-maps --stack-trace-limit=1000",
            DATABASE_NAME: process.env.DATABASE_NAME,
            DATABASE_USERNAME: process.env.DATABASE_USERNAME,
            DATABASE_PASSWORD: process.env.DATABASE_PASSWORD,
            DATABASE_HOST: process.env.DATABASE_HOST,
            DATABASE_PORT: process.env.DATABASE_PORT,
            DATABASE_DIALECT: process.env.DATABASE_DIALECT,
            REGION: process.env.REGION,
        },
    },
    // import the function via paths
    functions: {
        helloWorld
    },
    package: { individually: true },
    custom: {
        esbuild: {
            bundle: true,
            minify: false,
            sourcemap: true,
            exclude: ["aws-sdk"],
            target: "node14",
            define: { "require.resolve": undefined },
            platform: "node",
            concurrency: 10,
            external: ["pg"],
        },
        dotenv: {
            path: `config`,
        },
    },
};

module.exports = serverlessConfiguration;

akshay-scalex avatar May 23 '23 11:05 akshay-scalex

I'm seeing similar issues. Started happening 12 hours ago.

derekbar90 avatar May 23 '23 18:05 derekbar90

I'm seeing similar issues. Started happening 12 hours ago.

I'm not sure how it could be related to the latest release https://github.com/floydspace/serverless-esbuild/commit/49ad43e6cd3964e0ca04bbbac98f21935b40afd3

we have just changed the default build target from node12 to node16, could you explicitly try changing it? so we can understand if it caused the issue.

floydspace avatar May 25 '23 09:05 floydspace