I am learning Gulp and want to try to put my .css files on a remote server. I have installed Vinyl FTP for this. My Gulp file is as such:
Whenever I run the ftp command I get a message ERROR Error: Timeout while connecting to server
.
My gulpfile.js file is as such:
'use strict';
var gulp = require('gulp');
var gutil = require( 'gulp-util' );
var ftp = require( 'vinyl-ftp' );
/** FTP Configuration **/
var user = 'myusername';
var password = 'password';
var host = '123.456.789.100'; //I have also tried 'ftp.mysite.com'
var port = 21;
var localFilesGlob = ['css/*.css'];
var remoteFolder = '/css'
// helper function to build an FTP connection based on our configuration
function getFtpConnection() {
return ftp.create({
host: host,
port: port,
user: user,
password: password,
parallel: 5,
log: gutil.log
});
}
gulp.task('ftp-deploy', function() {
var conn = getFtpConnection();
console.log(conn); //<--this seems to have the correct info
return gulp.src(localFilesGlob, { base: '.', buffer: false })
.pipe( conn.newer( remoteFolder ) ) // only upload newer files
.pipe( conn.dest( remoteFolder ) )
;
});
Obviously, I've checked out the user name and password. I can connect to the server fine with my FTP client.
I've also tried swapping out 'base' with 'cwd'.
I am running this in Mac Terminal, if that matters.
Would anyone know what I've done wrong?
Your code looks fine to me. My guess would be an issue with
passive/active
ftp mode. It is usually the reason with ftps.What did you try with your FTP client (did you have active or passive mode?).
Apparently
vinyl-ftp
does not support it yet as it is on the TODO list.I'm afraid there is no workaround for the moment.