我无法迁移松露编译附带的标准合同。这就是我的所作所为:
truffle init
truffle compile
open other terminal and run testrpc
truffle migrate
并且前三步是顺利操作,但是当我运行松露迁移时,它会出现
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
我的版本列表:
node 9.1.0
truffle 4.0.1
testrpc 6.0.3
谢谢!
答案 0 :(得分:30)
您应该在配置文件truffle.js
中指定网络,该文件位于项目文件夹的根目录中。
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*" // Match any network id
}
}
};
答案 1 :(得分:2)
简单解决方案:
问题:当你运行推荐时,今天就会出现这种配置 终端中的“松露初始”。没有任何移民定义与以太坊cli(如geth或testrpc)沟通
// module.exports = {
// // See <http://truffleframework.com/docs/advanced/configuration>
// // to customize your Truffle configuration!
// };
所以,您必须在 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: "*"
}
}
};