web3.js icon indicating copy to clipboard operation
web3.js copied to clipboard

TypeError: Cannot read properties of undefined (reading 'givenProvider') when using import

Open mbledkowski opened this issue 3 years ago • 1 comments

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

mbledkowski avatar Jul 16 '22 21:07 mbledkowski

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,

Muhammad-Altabba avatar Aug 04 '22 06:08 Muhammad-Altabba

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.

github-actions[bot] avatar Oct 04 '22 00:10 github-actions[bot]

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.

Muhammad-Altabba avatar Dec 07 '22 09:12 Muhammad-Altabba