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

320
Vistas
How can the variable be inaccessible?

I have a NextJS app with some server side code that gets bundled with Webpack (default NextJS setup). When running this with the product build, I get the following error:

ReferenceError: Cannot access 'providers' before initialization

Looking at the generated bundle at the lines referenced by the error, I can see this:

const providers = {
    [_myapp_webapp_types__WEBPACK_IMPORTED_MODULE_0__.ProviderType.Provider0]: _provider0__WEBPACK_IMPORTED_MODULE_1__/* .provider0 */ .d,
    [_myapp_webapp_types__WEBPACK_IMPORTED_MODULE_0__.ProviderType.Provider1]: _provider1__WEBPACK_IMPORTED_MODULE_2__/* .provider1 */ .S
};
function getProvider(config) {
    return providers[config.type];
}

In my head, there can be nothing stopping providers from being initialised when the getProvider function is called. What is going on here, and what can I do about it?

EDIT: The code is within a separate file that gets imported by another file that calls the getProvider-function. This means (in my head) that the providers variable without doubt should be initialised as soon as the function is called (from outside the module).

(Also, everything works just fine when running locally)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Turns out the problem was solved by updating to the latest minor upgrade of NextJS. (So this was possibly a bug somewhere down the line.)

about 4 years ago · Juan Pablo Isaza Denunciar
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