Search code examples
ethereumtruffle

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!


Solution

  • 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