Hello all!
This morningI woke up pumped to work on a pet project and suddenly Payload just sprung like 15 errors talking about serving static files (I normally use Vite so Webpack is a completely different beast to me).
Anyway, here is the error:
in ./node_modules/body-parser/lib/read.js 20:11-26
Module not found: Error: Can't resolve 'zlib' in '/my/path/to/project/node_modules/body-parser/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: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
ERROR in ./node_modules/body-parser/lib/types/urlencoded.js 228:12-34
Module not found: Error: Can't resolve 'querystring' in '/my/path/to/project/node_modules/body-parser/lib/types'
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: { "querystring": require.resolve("querystring-es3") }'
- install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "querystring": false }
ERROR in ./node_modules/destroy/index.js 16:17-41
Module not found: Error: Can't resolve 'fs' in '/my/path/to/project/node_modules/destroy'
ERROR in ./node_modules/destroy/index.js 17:13-30
Module not found: Error: Can't resolve 'stream' in '/my/path/to/project/node_modules/destroy'
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: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
ERROR in ./node_modules/destroy/index.js 18:11-26
Module not found: Error: Can't resolve 'zlib' in '/my/path/to/project/node_modules/destroy'
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: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
ERROR in ./node_modules/etag/index.js 22:12-31
Module not found: Error: Can't resolve 'fs' in '/my/path/to/project/node_modules/etag'
ERROR in ./node_modules/express/lib/request.js 18:11-30
Module not found: Error: Can't resolve 'net' in '/my/path/to/project/node_modules/express/lib'
ERROR in ./node_modules/express/lib/utils.js 24:18-40
Module not found: Error: Can't resolve 'querystring' in '/my/path/to/project/node_modules/express/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: { "querystring": require.resolve("querystring-es3") }'
- install 'querystring-es3'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "querystring": false }
ERROR in ./node_modules/express/lib/view.js 18:9-22
Module not found: Error: Can't resolve 'fs' in '/my/path/to/project/node_modules/express/lib'
ERROR in ./node_modules/mime/mime.js 2:9-22
Module not found: Error: Can't resolve 'fs' in '/my/path/to/project/node_modules/mime'
ERROR in ./node_modules/parseurl/index.js 15:10-24
Module not found: Error: Can't resolve 'url' in '/my/path/to/project/node_modules/parseurl'
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: { "url": require.resolve("url/") }'
- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "url": false }
ERROR in ./node_modules/send/index.js 23:9-22
Module not found: Error: Can't resolve 'fs' in '/my/path/to/project/node_modules/send'
ERROR in ./node_modules/send/index.js 30:13-30
Module not found: Error: Can't resolve 'stream' in '/my/path/to/project/node_modules/send'
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: { "stream": require.resolve("stream-browserify") }'
- install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "stream": false }
ERROR in ./node_modules/send/index.js 31:11-26
Module not found: Error: Can't resolve 'util' in '/my/path/to/project/node_modules/send'
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: { "util": require.resolve("util/") }'
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "util": false }
ERROR in ./node_modules/serve-static/index.js 21:10-24
Module not found: Error: Can't resolve 'url' in '/my/path/to/project/node_modules/serve-static'
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: { "url": require.resolve("url/") }'
- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "url": false }
Everything was working perfectly yesterday and when I just booted up my local dev server, all of this blasted me in the face and won't let me continue until this is fixed. I have no idea where to start with this one. 😞
UPDATE & SOLUTION:
VSCode's Autocomplete imported expresses query which was conflicting with a variable I had. Yay embarrassing dev moments!
Glad you were able to find the solution! 👍
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.