Skip to content
New issue

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

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

Already on GitHub? # to your account

Module Not Found: "process/browser" Error in React Integration with @fileforge/pdfreader #1

Open
ANYURU opened this issue Oct 18, 2024 · 1 comment

Comments

@ANYURU
Copy link

ANYURU commented Oct 18, 2024

I am experiencing an issue while integrating @fileforge/pdfreader into my React project. After following the documentation and installing the package, I encountered a Webpack compilation error related to the missing process/browser module.

Error Details:
The following error occurs during the build process:
Screenshot 2024-10-18 at 12 50 19

Additionally, I tried adding a polyfill for process in my Webpack configuration, but the error persists. The issue seems to be related to how the module is handled within @fileforge/pdfreader.

Steps to Reproduce:

  1. Install @fileforge/pdfreader in a React project.
  2. Attempt to import and use the component in the project.
  3. Run the build using Webpack (or a React build tool like Create React App).

Expected Behavior:
The package should work without requiring a manual polyfill for Node.js modules like process.

Actual Behavior:
The build fails with the error above.

Environment:

  • OS: macOS
  • Node.js version: v20.18.0 | v22.7.0
  • Webpack version: 5.64.4
  • React version: 18.3.1
  • @fileforge/pdfreader version: 0.1.43

Attempts to Resolve:
I attempted to resolve the issue by:

  • Installing the process polyfill.
  • Modifying the Webpack configuration to include process/browser.
  • Ensuring that the paths are correctly set in the module resolution.

Despite these attempts, the error persists, suggesting a deeper issue with how @fileforge/pdfreader handles dependencies.

Request:
Could you provide guidance on how to resolve this error, or update the package to avoid requiring manual Node.js polyfills when used in a browser environment like React? If possible, an example of proper integration would also be very helpful.

Thank you for your time and assistance.

@Titou325
Copy link
Member

Hey @ANYURU, thanks for the detailed walkthrough!

Vite should handle bundling this gracefully, not sure why there are issues with Webpack specifically. It is likely being introduced by pdfjs-dist, but I can't really confirm at the moment.

Contributions regarding this are welcome!

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

No branches or pull requests

2 participants