Module http not found during webpack build
I got error like this in terminal, when I was running command yarn run start
in branch 194-integrate-openhive-chat:
ERROR in ./node_modules/cookies/index.js 12:11-26
Module not found: Error: Can't resolve 'http' in '/home/syncad/src/condenser/node_modules/cookies'
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: { "http": require.resolve("stream-http") }'
- install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "http": false }
resolve 'http' in '/home/syncad/src/condenser/node_modules/cookies'
Parsed request is a module
using description file: /home/syncad/src/condenser/node_modules/cookies/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in /home/syncad/src/condenser/src
single file module
using description file: /home/syncad/src/condenser/package.json (relative path: ./src/http)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/src/http doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/src/http.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/src/http.json doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/src/http.jsx doesn't exist
/home/syncad/src/condenser/src/http doesn't exist
looking for modules in /home/syncad/src/condenser/node_modules/cookies/node_modules
single file module
using description file: /home/syncad/src/condenser/node_modules/cookies/package.json (relative path: ./node_modules/http)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/cookies/node_modules/http doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/cookies/node_modules/http.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/cookies/node_modules/http.json doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/cookies/node_modules/http.jsx doesn't exist
/home/syncad/src/condenser/node_modules/cookies/node_modules/http doesn't exist
/home/syncad/src/condenser/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /home/syncad/src/condenser/node_modules
single file module
using description file: /home/syncad/src/condenser/package.json (relative path: ./node_modules/http)
no extension
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/http doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/http.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/http.json doesn't exist
.jsx
Field 'browser' doesn't contain a valid alias configuration
/home/syncad/src/condenser/node_modules/http.jsx doesn't exist
/home/syncad/src/condenser/node_modules/http doesn't exist
/home/syncad/src/node_modules doesn't exist or is not a directory
/home/syncad/node_modules doesn't exist or is not a directory
/home/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
@ ./node_modules/koa/lib/context.js 13:16-34
@ ./src/app/redux/UserSaga.js 26:17-43
@ ./src/shared/RootSaga.js 20:16-45
@ ./src/shared/UniversalRender.jsx 61:39-65
@ ./src/app/Main.js 23:23-56
I can see corresponding error in browser's console as well:
index.js:12 Uncaught Error: Cannot find module 'http'
Edited by Wojciech Barcik