Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Truffle migrate Error (after run testrpc)

I can´t migrate the standart contracts that come with truffle compile. Here´s what i do:

truffle init
truffle compile
open other terminal and run testrpc
truffle migrate

and the first three step is smooth operation,but when i run truffle migrate ,it appears

Error: No network specified. Cannot determine current network.
    at Object.detect (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43157:23)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:200497:19
    at finished (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:43085:9)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:198408:14
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:68162:7
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:163793:9
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160353:16
    at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160873:25)
    at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:160863:17)
    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:160838:16

My version list:

node 9.1.0
truffle 4.0.1
testrpc 6.0.3

Thank you!

like image 865
zengcaifei Avatar asked Nov 17 '17 06:11

zengcaifei


2 Answers

You should specify the network in the configuration file truffle.js, which is located in the root of your project folder.

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*" // Match any network id
    }
  }
};

Truffle configuration#networks

like image 144
leonzhao Avatar answered Oct 16 '22 13:10

leonzhao


Simple Solution:

Problem: this configuration is coming today while you run commend "truffle init" in terminal. there is no configration defined to communicate with ethereum cli (like geth or testrpc )

// module.exports = {
//   // See <http://truffleframework.com/docs/advanced/configuration>
//   // to customize your Truffle configuration!
// };

So, you have to change it like below in truffle.js

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545, // your rpc port (like geth rpc port or testrpc port )
      network_id: "*"    
    }
  }
};
like image 31
Shashwat Gupta Avatar answered Oct 16 '22 15:10

Shashwat Gupta