web3.js
web3.js copied to clipboard
TypeError: Cannot read properties of undefined (reading 'givenProvider') when using import
Is there an existing issue for this?
- [X] I have searched the existing issues
Current Behavior
When importing using import Web3 from "web3"; Web3 is undefined
Expected Behavior
Web3 should be imported
Steps to Reproduce
import Web3 from "web3";
const web3 = new Web3(Web3.givenProvider || '');
Web3.js Version
1.7.4
Environment
- Operating System: Arch Linux
- Browser: Node.js
- Node.js Version: v18.5.0
- NPM Version: 8.14.0
Anything Else?
No response
Hello @mbledkowski, Here is a working sample: https://codesandbox.io/s/unruffled-kowalevski-5bchxo?file=/index.ts If you are still facing this error, could you point to a public repo (or make one fast on codesandbox or a similar Cloud IDE)? Thanks,
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.
Hello @mbledkowski, Here is a working sample: https://codesandbox.io/s/unruffled-kowalevski-5bchxo?file=/index.ts If you are still facing this error, could you point to a public repo (or make one fast on codesandbox or a similar Cloud IDE)? Thanks,
Hello @mbledkowski, I hope that things work well with you after you checked the provided working sample. I am closing this issue. Feel free to reopen it if you still face this problem. And please provide more information on how we can reproduce it.