title: Error [ERR_STREAM_CANNOT_PIPE]: Cannot pipe, not readable nodejs
body: <pre><code>function unzipCode() {
      console.log('Unzipping contents...');
      return new Promise((resolve, reject) =&gt; {
        const files = [];
        unzip.open(filePath, { autoclose: false, lazyEntries: true }, (err, zipfile) =&gt; {
          if (err) reject;
          zipfile.readEntry();
          zipfile.on('entry', (entry) =&gt; {
            if (!sourceDirectoryRegEx.test(entry.fileName)) {
              console.log("  [X] Skipping: " + entry.fileName);
              zipfile.readEntry();
            }
            else {
              console.log("  [+] Unzipping: " + entry.fileName);
              if (/\/$/.test(entry.fileName)) {
                // directory file names end with '/'
                mkdirp(path.join(cwd, entry.fileName), (err) =&gt; {
                  if (err) reject;
                  zipfile.readEntry();
                });
              }
              else {
                zipfile.openReadStream(entry, (err, readStream) =&gt; {
                  if (err) reject;
                  // ensure parent directory exists
                  mkdirp(path.join(cwd, path.dirname(entry.fileName)), (err) =&gt; {
                    if (err) reject;
                    let stream = fs.createWriteStream(path.join(cwd, entry.fileName));
  
                    readStream.pipe(stream, { end: false });
  
                    //    console.log(readStream.pipe);
                    readStream.on('end', () =&gt; {
                      console.log('After write', entry.fileName);
                      // add file details to files array
                      files.push({
                        key: entry.fileName,
                        body: stream,
                      });
                      zipfile.readEntry();
  
                      readStream.unpipe(stream);
                      stream.end();
                    });
                  });
                });
              }
            }
          });
          zipfile.once('end', () =&gt; {
            zipfile.close();
            resolve(files);
          });
        });
      });
    }
  </code></pre>
  
  <p>I am trying to unzip some files in aws-lambda console using the function. The enviornment I've chosen is nodejs 12.x. It was running with nodejs 8.10. 
  <br />The exact error I'm encountering is <strong>Cannot pipe, not readable</strong>.
  <br />How to solve it?</p>