0

Here is the necessary part of the code, from where I keep receiving the following error:

const { Web3 } = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));

TypeError: Cannot read property 'providers' of undefined Although, the node packages for Web3 are installed. How can I solve this problem?. Thanks.

1

From the example removing the {} around Web3 in the first line should do the trick

const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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