0

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?

6
  • 1
    The screenshot actually says "compiled successfully", and the error which appears after that line is a runtime error. So to begin with, the title of your question is wrong. Commented Jul 7, 2020 at 20:13
  • Speaking of screenshots, please don't use them in your question. It is impossible to copy/paste from them in order to refer to your question or reproduce the problem. Use plain text only (no links either). Also, encapsulate any code that you post in your question with ``` at the beginning and ``` at the end. Commented Jul 7, 2020 at 20:14
  • @goodvibration I have made above changes and although I am thrilled to see I overlooked that it actually compiled. I am at a loss on how to get beyond this runtime error. Commented Jul 7, 2020 at 20:28
  • 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. Commented Jul 7, 2020 at 20:46
  • @CloudTechSupport It appears you have an extra space in the provider URL "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.
    – Ismael
    Commented Jul 8, 2020 at 20:59

1 Answer 1

1

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


0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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