Search code examples
reactjsethereumsoliditytruffle

Error: No network specified. Cannot determine current network


Truffle react-box not working as expected with default setup (with ganache and metamask)

I download and run ganache then I followed the first 4 steps in the readme and when I get to truffle migrate it says 'Error: No network specified. Cannot determine current network.' in the console.

enter image description here


Solution

  • On OSX 10.13.3 I went into the truffle.js file in the root folder and changed it to

    module.exports = {
      networks: {
        development: {
          host: '127.0.0.1',
          port: 7545,
          network_id: '*'
        }
      }
    };
    

    enter image description here

    npm run start in the terminal and everything works fine. Make sure you have ganache running in the background though.

    Also, make sure that the rpc server in ganache matches the host and port in the truffle file you just updated.

    enter image description here