getAccounts not working in web3js

accounts = await Web3.eth.getAccounts();
^

TypeError: Cannot read properties of undefined (reading 'getAccounts')

:1234: Code to reproduce


:laptop: Environment

1 Like

You can share your full code

I have a try like this:

const web3 = new Web3('https://eth.llamarpc.com');

(async () => {
  const accounts = await web3.eth.getAccounts();
  console.log('accounts', accounts);
})();

the result is:

accounts []
1 Like