Module Not Found: "process/browser" Error in React Integration with @fileforge/pdfreader
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:
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:
- Install
@fileforge/pdfreaderin a React project. - Attempt to import and use the component in the project.
- 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
processpolyfill. - 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.
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!