簡體   English   中英

做“松露初始化”的錯誤

[英]error on doing “Truffle init”

我是智能合約編程的新手,最近在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並找到解決方法時,我也遇到了類似的問題。

修改了cli.bundled.js:用請求替換了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 = {
           // 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
    +/******/ ]);

先決條件:

  1. 通過npm安裝請求(npm install -g request)
  2. 代理-所描述的設置環境在這里

沒有代碼,很難說出錯的地方。 但是,您是否在松露配置中指定的端口上運行了以太坊rpc節點。

松露配置

檢查您的錯誤代碼時,我看到您嘗試連接到151.101.8.133:443是否在此端口上運行了一個rpc節點?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM