首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在truffle.js中定义网络时语法错误

在truffle.js中定义网络时语法错误
EN

Ethereum用户
提问于 2018-06-02 03:45:55
回答 1查看 403关注 0票数 0

新手完全被以下语法错误所困扰。

代码语言:javascript
运行
复制
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)
EN

回答 1

Ethereum用户

发布于 2018-06-02 14:51:16

代码应该在module.exports中,如下所示:

module.exports = { networks: { development: { host: "localhost", port: 7545, network_id: "*" } } };

票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/50229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档