Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this.Client is not a constructor #3091

Open
Profluens-AntoineO opened this issue Nov 5, 2023 · 1 comment
Open

this.Client is not a constructor #3091

Profluens-AntoineO opened this issue Nov 5, 2023 · 1 comment

Comments

@Profluens-AntoineO
Copy link

Profluens-AntoineO commented Nov 5, 2023

Hello there!

I am stuck for a while on it so...

Here is my code :

import pg from "pg";
const { Pool } = pg;
export const pool = new Pool({
    host: process.env.PGHOST,
    user: process.env.PGUSER,
    password: process.env.PGPASSWORD,
    database: process.env.PGDATABASE,
    port: process.env.PGPORT,
    max: 20,
    idleTimeoutMillis: 30000,
    connectionTimeoutMillis: 2000,
})
const sqlQuery = "..."
const sqlParam = [...]
let  res = await pool.query(sqlQueryTest, sqlParam);

when executing it throws this exception :

/usr/src/app/node_modules/pg-pool/index.js:218
    const client = new this.Client(this.options)
                   ^

TypeError: this.Client is not a constructor
    at BoundPool.newClient (/usr/src/app/node_modules/pg-pool/index.js:218:20)
    at BoundPool.connect (/usr/src/app/node_modules/pg-pool/index.js:212:10)
    at BoundPool.query (/usr/src/app/node_modules/pg-pool/index.js:399:10)
    at updatePremiumEndDateForCustomer (file:///usr/src/app/actions.js:40:26)
    at startSubscription (file:///usr/src/app/actions.js:9:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v20.9.0

Any Idea ?

@broisnischal
Copy link

I am also facing same kinda issue

const client = new Client();
               ^


TypeError: import_pg.Client is not a constructor
    at <anonymous> (/home/nees/kabelinteriorsbackend/pg.ts:2:16)
    at Object.<anonymous> (/home/nees/kabelinteriorsbackend/pg.ts:2:20)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Object.S (/usr/local/lib/node_modules/tsx/dist/cjs/index.cjs:1:1292)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:345:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:294:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)

Node.js v20.10.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants