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

321
Views
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 answers
Answer question

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 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!