how can I fix the below web3-related errors for my Angular 14 dapp?
- I have tried to run npm i crypto, npm i http, etc.
- These errors occur when I try to run code that attempts to call a function from a smart contract:
this.manager = await report.methods.manager().call();
- I have tried implementing other solutions on StackOverflow and google, but have not been able to successfully fix these errors (e.g., Module not found: Error: Can't resolve 'url' in webpack 5/Angular 14).
- Here is a screenshot showing that I have tried ipm i url, added the webpack.config.ts file, and the dapp still does not load does to errors: https://i.stack.imgur.com/hePOW.jpg
index.js:561 [webpack-dev-server] ERROR in ../../node_modules/web3-providers-ws/lib/helpers.js 11:12-26
Module not found: Error: Can't resolve 'url' in 'C:\Users\bpha\Angular\node_modules\web3-providers-ws\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: { "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 }