Skip to content
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

ReferenceError: global is not defined in react-form-builder2.js #326

Open
HuzaifaDevelops opened this issue Oct 16, 2024 · 3 comments
Open

Comments

@HuzaifaDevelops
Copy link

Title: ReferenceError: global is not defined in react-form-builder2.js

Description:

I'm experiencing an issue with the react-form-builder2 library. When running my application, I encounter the following error:

Uncaught ReferenceError: global is not defined

Expected Behavior: The library should initialize without errors, allowing me to use the form builder in my application.

Actual Behavior: I receive the error Uncaught ReferenceError: global is not defined in the console, preventing the application from functioning correctly.

Environment:

Library version: "^0.19.0"
Node version: "v20.15.1"
React version: "^18.3.1"
Browser: Chrome

Screenshots
Screenshot 2024-10-16 104614

@cowdude679
Copy link

Same. This post fixed this particular issue

vitejs/vite#5912 (comment)

@Arpan738
Copy link

You encountered this error because this library relies on the global variable, which is available in Node.js environments but not in the browser. Vite, by default, doesn't provide polyfills for Node.js globals like global.

The solution mentioned in vitejs/vite#5912 is a temporary fix and wrong. Defining "global" in the config is not a good idea, as it may break your application when building it in a Linux environment.

I am also looking for an optimal solution and will let you know if I find one.

@cowdude679
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants