title: how to list ftp files in nodejs?
body: <p>I have this code to connect to an ftp server via nodejs using the node-ftp (<a href="https://www.npmjs.com/package/ftp" rel="nofollow noreferrer">https://www.npmjs.com/package/ftp</a>) package.</p>
  
  <p>Node version: v10.13.0
  I tried to change the next line to false.</p>
  
  <pre><code>socket.setKeepAlive(true);
  </code></pre>
  
  <pre><code>var Client = require('ftp');
  const fs = require('fs');
  const moment = require('moment');
  
  var c = new Client();
  var date;
  var filename;
  c.on('error', (err) =&gt; console.log(err));
  
  c.on('ready', function() {
  
      c.list((err, list) =&gt; {
          if (err) console.dir(err);
          console.dir(list);
          c.end();
      });
  
  });
  
  c.connect({ host: 'hostname', user: 'username', password: 'pass', debug: console.log.bind(console) });
  </code></pre>
  
  <p>the message you're printing on the console is as follows:</p>
  
  <pre><code>[connection] &lt; '220-FileZilla Server version 0.9.41 beta\r\n'
  [connection] &lt; '220 Welcome to ComexPerÃº FTP Server\r\n'
  [parser] &lt; '220-FileZilla Server version 0.9.41 beta\r\n220 Welcome to ComexPerÃº FTP Server\r\n'
  [parser] Response: code=220, buffer='FileZilla Server version 0.9.41 beta\r\nWelcome to ComexPerÃº FTP Server'
  [connection] &gt; 'USER username'
  [connection] &lt; '331 Password required for username\r\n'
  [parser] &lt; '331 Password required for username\r\n'
  [parser] Response: code=331, buffer='Password required for username'
  [connection] &gt; 'PASS pass'
  [connection] &lt; '230 Logged on\r\n'
  [parser] &lt; '230 Logged on\r\n'
  [parser] Response: code=230, buffer='Logged on'
  [connection] &gt; 'FEAT'
  [connection] &lt; '211-Features:\r\n'
  [connection] &lt; ' MDTM\r\n REST STREAM\r\n SIZE\r\n MLST type*;size*;modify*;\r\n MLSD\r\n'
  [connection] &lt; ' UTF8\r\n CLNT\r\n MFMT\r\n'
  [connection] &lt; '211 End\r\n'
  [parser] &lt; '211-Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST type*;size*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\n211 End\r\n'
  [parser] Response: code=211, buffer='Features:\r\n MDTM\r\n REST STREAM\r\n SIZE\r\n MLST type*;size*;modify*;\r\n MLSD\r\n UTF8\r\n CLNT\r\n MFMT\r\nEnd'
  [connection] &gt; 'TYPE I'
  [connection] &lt; '200 Type set to I\r\n'
  [parser] &lt; '200 Type set to I\r\n'
  [parser] Response: code=200, buffer='Type set to I'
  [connection] &gt; 'PASV'
  
  { Error: read ECONNRESET
      at TCP.onStreamRead (internal/stream_base_commons.js:111:27) errno: 'ECONNRESET', code: 'ECONNRESET', syscall: 'read' }
  
  </code></pre>