I am trying to deploy my contracts with the specific account the user is using instead of hard coding it. But in this code, I get an error as such:
Error: Cannot find module 'web3'
the truffle-config.js file is as follows:
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider('http://localhost:7545'));
var acc;
web3.eth.getCoinbase(function(err, account) {
if (err === null) {
acc=account;
}
})
module.exports = {
networks: {
development: {
host: "127.0.0.1",
port: 7545,
network_id: "*", // Match any network id
from: acc
},
develop: {
port: 8545
}
}
};
How to overcome this error?