Although it compiles successfully
truffle migrate --network ganache gives the following error:
Unknown network "ganache". See your Truffle configuration file for available networks.
I believe I have it wired correctly
Truffle v5.1.34 (core: 5.1.34) Node v12.18.0
Code sample:
const path = require("path");
require("dotenv").config({path: "./.env"});
const HDWalletProvider = require("@truffle/hdwallet-provider");
const MetaMaskAccountIndex = 0;
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "client/src/contracts"),
networks: {
development: {
port: 7545,
host: "127.0.0.1",
network_id: "*"
}
},
ganache: {
provider: function() {
return new HDWalletProvider(process.env.MNEMONIC, "http://127.0.0.1:7545", MetaMaskAccountIndex)
},
network_id: 5777
},
compilers: {
solc: {
version: "0.6.1"
}
}
};
I believe I have it wired in my truffle-config.js file correctly. Any idea why this is going on?
Invalid JSON RPC response: ""
is typically because there is no active node (Ganache, Geth, Parity, etc), which is listening on the port that your application (Truffle in this case) is configured to work with."http://127.0.0.1: 7545"
, just before the port number. Another thing to check is ganache is running on that port, 8545 is also popular for that.