You're encountering a common issue with Webpack 5. Unlike Webpack 4, Webpack 5 no longer automatically includes polyfills for Node.js core modules when they're used in browser environments.
You need to update your webpack configuration to provide fallbacks for these Node.js core modules. Here's how to fix it:
next.config.js
You'll need to install these polyfill packages:
npm install --save-dev crypto-browserify stream-browserify stream-http https-browserify browserify-zlib path-browserify os-browserify url querystring-es3 process util bufferA better approach is to avoid using Node.js-specific libraries directly in your frontend code. Instead:
/pages/api or /app/api directory)This is a more maintainable approach as it properly separates client and server code.
app/api/send-email/route.js
Then call this API from your client-side code:
// Client-side code
async function sendEmail(data) {
const response = await fetch('/api/send-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});
return response.json();
}This approach is more maintainable and follows best practices for separating client and server code.
I see you're working on the Lissomsoft website, which appears to be a React application using react-router-dom. Based on the files you've shared (App.js, setupTests.js, and reportWebVitals.js), this looks like a Create React App project.
In Create React App projects, the webpack configuration is hidden and managed by react-scripts. You don't directly edit a webpack.config.js file unless you've "ejected" the app.
To fix your Node.js polyfill errors, you have two options:
Create a file called craco.config.js in the root of your project:
craco.config.js
Then install CRACO and the necessary polyfills:
npm install @craco/craco crypto-browserify stream-browserify stream-http https-browserify browserify-zlib path-browserify os-browserify url querystring-es3 process util bufferUpdate your package.json scripts:
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
}A better approach is to move any code that uses Node.js-specific libraries (like googleapis, nodemailer, etc.) to a backend service. This is a cleaner architecture and avoids the need for browser polyfills.
If you're using these libraries for features like sending emails or accessing Google APIs, create a simple backend API (using Express.js, Next.js API routes, or any other server technology) and call that API from your React frontend.
Based on your error logs, it looks like you're trying to use libraries like:
These are all Node.js libraries that aren't designed to run in browsers. Check your codebase for imports of these libraries and consider moving that functionality to a backend service.
Would you like me to help you identify which specific components or files in your project might be importing these problematic libraries?
Compiled with problems:
×
ERROR in ./node_modules/browserify-zlib/lib/binding.js 4:13-30
Module not found: Error: Can't resolve 'assert' in 'C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\browserify-zlib\lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }
ERROR in ./node_modules/browserify-zlib/lib/index.js 7:13-33
Module not found: Error: Can't resolve 'assert' in 'C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\browserify-zlib\lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }
ERROR in ./node_modules/gaxios/node_modules/https-proxy-agent/dist/index.js 45:33-50
Module not found: Error: Can't resolve 'assert' in 'C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\gaxios\node_modules\https-proxy-agent\dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "assert": require.resolve("assert/") }'
- install 'assert'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "assert": false }
ERROR in node:events
Module build failed: UnhandledSchemeError: Reading from "node:events" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:984:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\Hook.js:18:14)
at Object.processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:980:8)
at processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
at iteratePitchingLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
at runLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
at NormalModule._doBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:965:3)
at NormalModule.build (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1155:15)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1422:12
at NormalModule.needBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1477:32)
at Compilation._buildModule (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1403:10)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:340:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncQueue._startProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:330:26)
at AsyncQueue._ensureProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:317:12)
at process.processImmediate (node:internal/timers:478:21)
ERROR in node:process
Module build failed: UnhandledSchemeError: Reading from "node:process" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:984:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:980:8)
at processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
at iteratePitchingLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
at runLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
at NormalModule._doBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:965:3)
at NormalModule.build (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1155:15)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1422:12
at NormalModule.needBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1477:32)
at Compilation._buildModule (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1403:10)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:340:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncQueue._startProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:330:26)
at AsyncQueue._ensureProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:317:12)
at process.processImmediate (node:internal/timers:478:21)
ERROR in node:util
Module build failed: UnhandledSchemeError: Reading from "node:util" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:984:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at Object.processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:980:8)
at processResource (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:220:11)
at iteratePitchingLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:171:10)
at runLoaders (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\loader-runner\lib\LoaderRunner.js:398:2)
at NormalModule._doBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:965:3)
at NormalModule.build (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1155:15)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1422:12
at NormalModule.needBuild (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\NormalModule.js:1477:32)
at Compilation._buildModule (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\Compilation.js:1403:10)
at C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:340:10
at Hook.eval [as callAsync] (eval at create (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncQueue._startProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:330:26)
at AsyncQueue._ensureProcessing (C:\Users\SRIRAGHAVAN K\OneDrive\Desktop\lissomsoft\lissomsoft\node_modules\webpack\lib\util\AsyncQueue.js:317:12)
at process.processImmediate (node:internal/timers:478:21) this is the last prompt plz solve my issue