Estoy tratando de importar Pool, pero recibo un error.
Este es el error, que se lanza:
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.
Este es mi código:
import { Pool } from "pg"; dotenv.config(); const databaseConfig = { connectionString: process.env.DATABASE_URL }; const pool = new Pool(databaseConfig); export default pool;
Debe utilizar la exportación predeterminada:
import pg from "pg"; const { Pool } = pg; dotenv.config(); const databaseConfig = { connectionString: process.env.DATABASE_URL }; const pool = new Pool(databaseConfig); export default pool;