新手完全被以下语法错误所困扰。
dwayne@dwayne-UX305CA:~/HelloTruffle$ cat truffle.js
//module.exports = {
// See
// to customize your Truffle configuration!
//};
networks: {
ganache: {
host: "localhost",
port: 7545,
network_id: "*"
}
}
dwayne@dwayne-UX305CA:~/HelloTruffle$ truffle migrate --reset --compile-all --network ganache
/home/dwayne/HelloTruffle/truffle.js:9
port: 7545,
^
SyntaxError: Unexpected token :
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Function.Config.load (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-config/index.js:259:1)
at Function.Config.detect (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-config/index.js:248:1)
at Object.run (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-core/lib/commands/migrate.js:35:1)
at Command.run (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-core/lib/command.js:101:1)
at Object. (/usr/lib/node_modules/truffle/build/webpack:/~/truffle-core/cli.js:16:1)
at __webpack_require__ (/usr/lib/node_modules/truffle/build/webpack:/webpack/bootstrap b4601922d6f11f8bff0b:19:1)
at /usr/lib/node_modules/truffle/build/webpack:/webpack/bootstrap b4601922d6f11f8bff0b:65:1
at Object. (/usr/lib/node_modules/truffle/build/cli.bundled.js:71:10)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
dwayne@dwayne-UX305CA:~/HelloTruffle$ truffle version
Truffle v4.1.11 (core: 4.1.11)
Solidity v0.4.24 (solc-js)
发布于 2018-06-02 14:51:16
代码应该在module.exports中,如下所示:
module.exports = { networks: { development: { host: "localhost", port: 7545, network_id: "*" } } };
https://ethereum.stackexchange.com/questions/50229
复制相似问题