使用vinyl-ftp吞咽错误:抱歉,此服务器不接受明文会话

时间:2016-07-19 14:26:49

标签: javascript ftp gulp vinyl-ftp

在gulp中使用vinyl-ftp在FTP服务器上上传和更新文件时遇到问题。

我的gulpfile.js代码是:

var gutil = require('gulp-util');
var ftp = require('vinyl-ftp');

gulp.task( 'deploy-dev', function () {

    var conn = ftp.create( {
        host:     'my_server_host_name',
        user:     'my_server_username',
        password: 'my_server_password',
        parallel: 5,
        log:      gutil.log
    } );

    var globs = [
        'assets/**',
        '!node_modules/**',
        '!assets/img/**',
        '!assets/bower_componets/**',
        '!assets/dist/**'
    ];

    // using base = '.' will transfer everything to /public_html correctly 
    // turn off buffering in gulp.src for best performance 

    return gulp.src( globs, { base: 'assets/', buffer: false } )
        .pipe( conn.newer( '/public_html/demos/P-09-Sakha/html' ) ) // only upload newer files 
        .pipe( conn.dest( '/public_html/demos/P-09-Sakha/html' ) );

} );

// Default Task
gulp.task('default', [ 'scripts','css','watch', 'deploy-dev']);

在我的终端中,我看到以下错误:

[16:58:12] Using gulpfile E:\xamp\htdocs\projects\P-09-sakha\html\gulpfile.js
[16:58:12] Starting 'scripts'...
[16:58:12] Starting 'css'...
[16:58:12] Starting 'watch'...
[16:58:12] Finished 'watch' after 74 ms
[16:58:12] Starting 'deploy-dev'...
[16:58:12] CONN
[16:58:12] CONN
[16:58:14] ERROR Error: Sorry, cleartext sessions are not accepted on this serve
r.
    at makeError (E:\xamp\htdocs\projects\P-09-sakha\html\node_modules\vinyl-ftp
\node_modules\ftp\lib\connection.js:1067:13)
    at Parser.<anonymous> (E:\xamp\htdocs\projects\P-09-sakha\html\node_modules\
vinyl-ftp\node_modules\ftp\lib\connection.js:113:25)

如果有人能在这方面帮助我,我将非常感激。

1 个答案:

答案 0 :(得分:0)

尝试设置options securesecureOptions

var conn = ftp.create( {
    host:     'my_server_host_name',
    user:     'my_server_username',
    password: 'my_server_password',
    parallel: 5,
    log:      gutil.log,
    secure:   true,
    secureOptions: {
      rejectUnauthorized: false
    }
} );