truffle migrate 报错解决办法

truffle版本4.0.4
truffle migrate 

Error: No network specified. Cannot determine current network.

    at Object.detect (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41338:23)

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:202239:19

    at finished (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:41266:9)

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:200593:14

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:63299:7

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:165077:9

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:161676:16

    at replenish (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:162196:25)

    at iterateeCallback (/usr/local/lib/node_modules/truffle/build/cli.bundled.js:162186:17)

    at /usr/local/lib/node_modules/truffle/build/cli.bundled.js:162161:16
导致上面异常的原因为是因为truffle.js里面未配置链接合约发布的环境地址,找到对应的truffle.js文件,修改代码为类似如下配置即可解决问题:


module.exports = {
    networks: {
        development: {
            host: "localhost",
            port: 8545,
            network_id: "*" // 匹配任何network id
         }
    }
};



你可能感兴趣的:(区块链)