简体   繁体   中英

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:

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:

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.

Modified the cli.bundled.js: replaced https.request with 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
    +/******/ ]);

Prerequisite:

  1. Install request via 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.

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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