Skip to content

cannot access variable before initialization error (Node 20 upgrade related?) #1827

@thescientist13

Description

@thescientist13

Describe the bug

Running this repo results in an error from Stackblitz when booting up that does not occur locally running the exact same version of Node (v20.19.0)

ReferenceError: Cannot access 'generateCompilation' before initialization
    at Module.get [as generateCompilation] (file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/lifecycles/compile.js:7:55)
    at run (file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/index.js:69:52)
    at eval (file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/index.js:106:1)
    at Generator.next (<anonymous>)
    at _0x39070d (https://parignzygjgithub-0ce4.w-credentialless-staticblitz.com/blitz.fb22cd3d.js:31:831295)
    at _0x138fc6.<computed>._0x46287a (https://parignzygjgithub-0ce4.w-credentialless-staticblitz.com/blitz.fb22cd3d.js:31:831837)
    at async ModuleJob.run (https://parignzygjgithub-0ce4.w-credentialless-staticblitz.com/builtins.f5b24229.js:158:3353)
    at async ModuleLoader.import (https://parignzygjgithub-0ce4.w-credentialless-staticblitz.com/builtins.f5b24229.js:157:5061)
    at async asyncRunEntryPointWithESMLoader (https://parignzygjgithub-0ce4.w-credentialless-staticblitz.com/builtins.f5b24229.js:168:797)

Link to the blitz that caused the error

https://stackblitz.com/github/projectevergreen/greenwood-getting-started

Steps to reproduce

  1. Go to the Stackblitz
  2. It should automatically run npm run dev (or manually run npm run dev or npm run build)

Expected behavior

It should start the dev server and show a landing page (or successfully complete when running npm run build)
Image

Parity with Local

Screenshots

Image

Platform

  • OS: macOS
  • Browser: Chrome
  • Version: 135

Additional context

I feel this is related to the recent bump in NodeJS version since I had tested this a few weeks ago prior to the bump when Web Containers was still on Node 18 and everything was working then.

In regards to the stack trace, this is the immediate line in Greenwood it is complaining about, but I don't see any reason why there would be a "before initialization" error?
https://github.com/ProjectEvergreen/greenwood/blob/v0.32.0/packages/cli/src/lifecycles/compile.js

(file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/lifecycles/compile.js:7:55)

For the rest of the stack trace

at run (file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/index.js:69:52)
at eval (file:///home/projects/parignzygj.github/node_modules/@greenwood/cli/src/index.js:106:1)

there must be some sort of Stackblitz secret sauce happening to this file since it is identifying a line (106) that doesn't exist in the source (source is less than 100 lines)
https://github.com/ProjectEvergreen/greenwood/blob/v0.32.0/packages/cli/src/index.js

Here is where generateCompilation is called from though, for reference
https://github.com/ProjectEvergreen/greenwood/blob/v0.32.0/packages/cli/src/index.js#L60

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtracked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions