I'm trying to import Pool, but i am getting an error.
This is the error, which get thrown:
import { Pool } from "pg";
^^^^
SyntaxError: Named export 'Pool' not found. The requested module 'pg' is a CommonJS module, which may not support all module.exports as named exports.
This is my code:
import { Pool } from "pg";
dotenv.config();
const databaseConfig = { connectionString: process.env.DATABASE_URL };
const pool = new Pool(databaseConfig);
export default pool;
You should use the default export:
import pg from "pg";
const { Pool } = pg;
dotenv.config();
const databaseConfig = { connectionString: process.env.DATABASE_URL }; const pool = new Pool(databaseConfig);
export default pool;