1

I am trying to connect and interact with a local blockchain (using ganache-cli) through the web3js library. I have created a local website that uses web3js library but I keep getting the following error message in my browser console when I try to load the web page.

ReferenceError: require is not defined

web3.min.js:1:636

    <anonymous> https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js:1

ReferenceError: Web3 is not defined

I am using the following code

<script src="https://cdn.jsdelivr.net/gh/ethereum/web3.js/dist/web3.min.js"></script>

1 Answer 1

0

Looks like there's a bug report already filed for this. It will be fixed in version 1.2.2 (current version is 1.2.1).

Assuming this ever worked, you can try using a prior version

<script src="https://cdn.jsdelivr.net/gh/ethereum/[email protected]/dist/web3.min.js"></script>

where you replace 1.2.1 with the version that didn't have this issue.

3
  • 1
    thank you for the answer. now the error goes away when using 1.2.0 but when trying to access the account addresses, the return is null. any idea why is that happening.
    – user57527
    Jan 16, 2020 at 6:41
  • better to open as a separate question, as depending on how you do it, it could be a different issue. Most commonly I see people forget to use await when calling web3 functions like getAccounts. Jan 16, 2020 at 15:30
  • this is a new requirement as i have read to call the await, correct?
    – user57527
    Jan 18, 2020 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.