Module not found errors
See original GitHub issueHi, I have several errors of the same type when I try to use require("@alch/alchemy-web3")
. I’m following this guide
Errors look like:
Compiled with problems:
ERROR in ./node_modules/cipher-base/index.js 3:16-43
Module not found: Error: Can't resolve 'stream' in '/home/.../node_modules/cipher-base'
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/eth-lib/lib/bytes.js 9:193-227
Module not found: Error: Can't resolve 'crypto' in '/home/.../node_modules/eth-lib/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: { "crypto": require.resolve("crypto-browserify") }'
- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "crypto": false }
ERROR in ./node_modules/ethereumjs-util/dist.browser/account.js 39:31-48
Module not found: Error: Can't resolve 'assert' in '/home/.../node_modules/ethereumjs-util/dist.browser'
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 }
I tried to run the compiled tutorial but got the same errors.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (1 by maintainers)
@gpalshin thanks for sharing! good news is that it looks like it’s known issue for webpack 5 that’s being resolved. I managed to do a hacky work-around it, credit: https://github.com/facebook/create-react-app/issues/11756
This is a documented issue with webpack 5. You can read more about how to add the missing polyfills manually in the web3 documentation.
I’m going to mark this issue as closed but feel free to ask any other questions you may have!