TypeError: Cannot read properties of undefined (reading 'AlchemyProvider')
Hi, I just want to get the latest block number . I followed the docs, but getting the error
```
const provider = new ethers.providers.AlchemyProvider(
^
TypeError: Cannot read properties of undefined (reading 'AlchemyProvider')
at Object.<anonymous> (D:\BlockChain\Ether JS\readBlockchain.js:5:39)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
```
Here is my code :
```javascript
const { ethers } = require("ethers");
const network = "mainnet";
const demo = api_key;
const provider = new ethers.providers.AlchemyProvider(
network,
demo
);
const querryBlockchain = async () => {
const blockNumber = await provider.getBlockNumber();
console.log(blockNumber);
};
querryBlockchain();
```
Posted by Asir Shahriar Roudra over 1 year ago