在做“松露初始化”时出错

我是新来的智能合约编程,最近在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) 

下一次我运行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) 

任何想法如何解决这个问题

当我尝试在一个公司的http代理之后执行truffle init时,我也遇到了类似的问题,并find了一个解决方法。

修改了cli.bundled.js:用请求replace了https.request

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 = {
            //会以一种我们无法捕捉的方式失败,所以我们必须自己做。
           返回新的Promise(function(accept,reject){

     -  var options = {
     - 方法:'HEAD',
     - 主持人:'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 error(new Error(“Example'”+ name +“'does not exist.If you believe that this is an error,Please contact Truffle support。”));
                } else if(r.statusCode!= 200){
     @@ -202425,7 +202421,6 @@ var Init = {
                }
               接受();
              });
     -  req.end();

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

      / *** /})
     -  / ****** /]);
     \文件结尾没有换行符
     + / ****** /]);

先决条件:

  1. 通过npm安装请求(npm install -g request)
  2. 代理 – 设置环境如下所述

没有代码,很难说出错的地方。 但是,你有一个在truffleconfiguration中指定的端口上运行的ethereum rpc节点吗?

松露configuration

当检查你的错误代码,我看到你尝试连接到151.101.8.133:443是否有一个rpc节点上运行此端口?