Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

571
Views
"Error de tipo: no se puede leer la propiedad 'config' de undefined" en dotenv

Estoy tratando de obtener acceso a mi archivo .env a través del módulo dotenv , pero recibo el siguiente error

 dotenv.config(); ^ TypeError: Cannot read property 'config' of undefined

Tengo dotenv instalado en node_modules y package.json , mi archivo .env está en la carpeta raíz y creo que todo está escrito correctamente, pero no funciona por alguna razón. He intentado reinstalar el módulo, no ayudó

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

prueba lo siguiente:

 require('dotenv').config({path: __dirname + '/.env'})

En mecanografiado

 import * as dotenv from 'dotenv' dotenv.config({path: __dirname + '/.env'})
over 4 years ago · Santiago Trujillo Report

0

Otra forma de solucionar esto es habilitar esModuleInterop en las opciones del compilador de TypeScript.

Abra tsconfig.json y agregue esta línea:

 "esModuleInterop": true,

para que puedas importarlo así:

 import hello from 'hello-world';
over 4 years ago · Santiago Trujillo Report

0

prueba esto:

 const path = require('path') require('dotenv').config({ path: path.resolve(__dirname, '../.env') })
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!