简体   繁体   中英

Error: write EPIPE when trying to upload file to FTP using gulp

I've got a task to deploy some stylesheets out to a server using FTP and about 80% of the time I get this error,

Error: write EPIPE
  at _errnoException (util.js:1022:11)
  at WriteWrap.afterWrite [as oncomplete] (net.js:880:14)

I'm using vinyl-ftp to upload the file as seen in the code here,

var conn = ftp.create({
    host: 'host',
    user: 'user',
    password: 'pass',
    parallel: 10,
    idleTimeout: 10000,
    reload: true,
    secure: true,
    secureOptions: {rejectUnauthorized: false},
    log: gutil.log
});

// What files to transfer over (can be used in case there are more files to be uploaded in the future)
var globs = [
    localDir + '/' + jobName + 'Default.css'
];

gutil.log("Local File: " + globs[0]);

var remoteDir = '/' + environment + '/css/' + clientName + '/' + jobName;

gutil.log("Remote Dir: " + remoteDir);

return gulp.src(globs, {buffer: false}).pipe(conn.dest(remoteDir));

The server that I'm uploading to is using FTP-SSL (Explicit AUTH TLS). I'm not sure if that's what's causing the issue but I've tried catching the error and adding an onerror event to process.stdout but none of them work. When the error does trip it uploads an empty file to my server.

It'd be great to find a solution to this or better yet a different FTP package.

Edit 1: I'm on Windows.

您可以使用SSH连接https://www.tecmint.com/rsync-local-remote-file-synchronization-commands/将rsync用于同步本地和服务器

Finally just said screw it and changed what module I was using. node-ftp only throws the EPIPE error about 5% of the time compared to the original 80%. You can also catch the error which is useful because I catch it and try to upload the file again.

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