TransWikia.com

Unknown network ganache

Ethereum Asked by CloudTech Support on November 12, 2021

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?

One Answer

Another problem is that 'ganache' section is outside 'networks'.

  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
    },
  },


Answered by Ismael on November 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP