Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

174
Vistas
is there a way to import { pool } from pg

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;
7 months ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

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;
7 months ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos