• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

204
Vistas
Next.js's loadEnvConfig fails to load environment variables in Cypress' support file

I need some of the environment variables from my Next.js project in my Cypress tests and it seems that the proper way to do that is to use loadEnvConfig from @next/env.

Cypress enables a way to run code before each test via its support file.

This is what my support file looks like:

import { loadEnvConfig } from '@next/env'
import './commands'

loadEnvConfig('/path/to/my/project')

When I run Next in dev mode and then Cypress I get the following errors in the console:

index.js:1 Failed to load env from .env.production.local TypeError: t.statSync is not a function
    at loadEnvConfig (index.js:1)
    at Object../cypress/support/index.js (index.js:4)
    at __webpack_require__ (bootstrap:19)
    at Object.0 (tests?p=cypress/support/index.js:682)
    at __webpack_require__ (bootstrap:19)
    at eval (bootstrap:83)
    at eval (bootstrap:83)
    at eval (<anonymous>)

There are three more similar ones, for .env.local, .env.production, and .env.

almost 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda