简体   繁体   English

做“松露初始化”的错误

[英]error on doing “Truffle init”

I am new to smart contract programming, recently installed truffle using npm on Node(version: 6.10.3) When I run the command truffle init first time, I received this error: 我是智能合约编程的新手,最近在Node上使用npm安装了松露(版本:6.10.3)当我第一次运行命令truffle init时,我收到了这个错误:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: connect ETIMEDOUT 151.101.8.133:443
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)

The next time I run truffle init , I got ths error: 下次我运行truffle init ,我得到了错误:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at exports._errnoException (util.js:1018:11)
    at TLSWrap.onread (net.js:568:26)

Any idea on how to resolve this 关于如何解决这个问题的任何想法

I was also facing a similar issue when I tried to execute truffle init behind a corporate http proxy and found a workaround. 当我尝试在公司的http代理后面执行truffle init并找到解决方法时,我也遇到了类似的问题。

Modified the cli.bundled.js: replaced https.request with request 修改了cli.bundled.js:用请求替换了https.request

Diff: DIFF:

diff --git a/build/cli.bundled.js b/build/cli.bundled.js
    index 01c69e3..aa2605c 100755
    --- a/build/cli.bundled.js
    +++ b/build/cli.bundled.js
    @@ -202412,12 +202412,8 @@ var Init = {
           // will fail spectacularly in a way we can't catch, so we have to do it ourselves.
           return new Promise(function(accept, reject) {

    -        var options = {
    -          method: 'HEAD',
    -          host: 'raw.githubusercontent.com',
    -          path: '/trufflesuite/' + expected_full_name + "/master/truffle.js"
    -        };
    -        req = https.request(options, function(r) {
    +        var request = require('request');
    +        request({ method: 'HEAD', uri: 'https://raw.githubusercontent.com/trufflesuite/'+expected_full_name+'/master/truffle.js'}, function (error, r, body) {
               if (r.statusCode == 404) {
                 return reject(new Error("Example '" + name + "' doesn't exist. If you believe this is an error, please contact Truffle support."));
               } else if (r.statusCode != 200) {
    @@ -202425,7 +202421,6 @@ var Init = {
               }
               accept();
             });
    -        req.end();

           });
         }).then(function() {
    @@ -212634,4 +212629,4 @@ module.exports = require("solc");
     module.exports = require("string_decoder");

     /***/ })
    -/******/ ]);
    \ No newline at end of file
    +/******/ ]);

Prerequisite: 先决条件:

  1. Install request via npm (npm install -g request) 通过npm安装请求(npm install -g request)
  2. Proxy - setup enviroment as described here 代理-所描述的设置环境在这里

Without code it is pretty difficult to say where this goes wrong. 没有代码,很难说出错的地方。 But do you have a ethereum rpc node running on the port specified in the truffle configuration. 但是,您是否在松露配置中指定的端口上运行了以太坊rpc节点。

Truffle configuration 松露配置

When inspecting your error code I see you try to connect to 151.101.8.133:443 is there an rpc node running on this port? 检查您的错误代码时,我看到您尝试连接到151.101.8.133:443是否在此端口上运行了一个rpc节点?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM