Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
thescientist13 opened this issue Apr 17, 2025 · 5 comments
Closed
1 task done
Labels
bug Something isn't working tracked

Comments

@thescientist13
Copy link

thescientist13 commented Apr 17, 2025

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

@SamVerschueren
Copy link
Contributor

This is indeed a Node.js 20 upgrade bug. I'll prioritize this!

@SamVerschueren SamVerschueren added bug Something isn't working tracked labels Apr 22, 2025
@SamVerschueren
Copy link
Contributor

I found the issue and will create a PR to fix this. Will keep you posted once it landed!

@thescientist13
Copy link
Author

Great, thank you for the updates!

@SamVerschueren
Copy link
Contributor

This is now working again! Thanks for flagging this @thescientist13 🙏 !

@thescientist13
Copy link
Author

Awesome, thanks so much @SamVerschueren . Just tested and everything is worked well 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked
Projects
None yet
Development

No branches or pull requests

2 participants