Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
Why is process.env.DATABASE undefined on macOS?

I have a MERN application that runs fine on a Windows machine, but when trying to deploy it to a colleague's macOS machine we're getting the below error. Console logging process.env.DATABASE reveals it is undefined on the macOS machine. We tried setting the variable by running export NODE_ENV=development in the console but still get the same error.

index.js

const express = require('express');
const session = require('express-session');
const mongoose = require('mongoose');
const MongoStore = require('connect-mongo');

const db = require('./database');
const router = require('./routes');

const app = express();

require('dotenv').config({ path: 'variables.env' });

app.use(session({
  secret: process.env.SECRET,
  key: process.env.KEY,
  resave: false,
  saveUninitialized: false,
  store: new MongoStore({ mongoUrl: process.env.DATABASE })
}));

app.use('/api', router);

app.set('port', process.env.PORT || 8000);

const server = app.listen(app.get('port'), () => {
  console.log(`Express running on port ${server.address().port}`);
});

variables.env

NODE_ENV=development
DATABASE=database path

error in console:

> server@1.0.0 start
> node ./index.js
Assertion failed: You must provide either mongoUrl|clientPromise|client in options
/Users/user/Documents/ATT-main/server/node_modules/connect-mongo/build/main/lib/MongoStore.js:119
            throw new Error('Cannot init client. Please provide correct options');
            ^
Error: Cannot init client. Please provide correct options
    at new MongoStore (/Users/user/Documents/ATT-main/server/node_modules/connect-mongo/build/main/lib/MongoStore.js:119:19)
    at Object.<anonymous> (/Users/user/Documents/ATT-main/server/index.js:32:10)

What am I missing?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda