【问题标题】:gulp-sftp error on gulp-sftpgulp-sftp 上的 gulp-sftp 错误
【发布时间】:2017-03-11 19:31:07
【问题描述】:

我已经使用 gulp-sftp 设置了一个 gulp 任务,并尝试了两个站点来连接它但没有成功。我用 Filezilla 都试过了,都在连接。

我的任务如下:

var sftp = require('gulp-sftp');        
gulp.task('sftp', function () {
        return gulp.src('dist/**/*')
            .pipe(sftp({
                host: 'waws-prod-sn1-015.ftp.azurewebsites.windows.net',
                user: 'fwd16\$fwd16',
                pass: 'xxxxxx',
                remotePath: '/site/wwwroot'
            }));
    });

我得到的回应如下:

bash-3.2$ gulp sftp                                                                                                                            
[22:29:18] Using gulpfile ~/Desktop/gulp-starter-csstricks/gulpfile.js                                                                         
[22:29:18] Starting 'sftp'...                                                                                                                  
[22:29:18] Authenticating with password.                                                                                                       
[22:29:28] 'sftp' errored after 10 s                                                                                                           
[22:29:28] Error in plugin 'gulp-sftp'                                                                                                         
Message:                                                                                                                                       
    Timed out while waiting for handshake                                                                                                      
Details:                                                                                                                                       
    level: connection-timeout                                                                                                                  
[22:29:28] gulp-sftp SFTP abrupt closure                                                                                                       
[22:29:28] Connection :: close

我更喜欢使用 auth 方法,因为我不想在 gulp 文件中公开用户和 pwd,并且我将 .ftppass 添加到我的 .gitignore 中。

如果我在 .ftppass 文件中添加用户和密码并将任务更改为以下内容:

gulp.task('sftp', function () {
    return gulp.src('dist/**/*')
        .pipe(sftp({
            host: 'waws-prod-sn1-015.ftp.azurewebsites.windows.net',
            authFile:'.ftppass',
            auth: 'keyMain',
            remotePath: '/site/wwwroot'
        }));
}); 

我收到以下错误:

bash-3.2$ gulp sftp                                                                                                                            
[22:22:55] Using gulpfile ~/Desktop/gulp-starter-csstricks/gulpfile.js                                                                         
[22:22:55] Starting 'sftp'...                                                                                                                  
[22:22:55] 'sftp' errored after 7.52 ms                                                                                                        
[22:22:55] SyntaxError: Unexpected token $ in JSON at position 36                                                                              
    at Object.parse (native)                                                                                                                   
    at module.exports (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/gulp-sftp/index.js:33:25)                                     
    at Gulp.<anonymous> (/Users/sohail/Desktop/gulp-starter-csstricks/gulpfile.js:86:15)                                                       
    at module.exports (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/lib/runTask.js:34:7)                             
    at Gulp.Orchestrator._runTask (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:273:3)                      
    at Gulp.Orchestrator._runStep (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:214:10)                     
    at Gulp.Orchestrator.start (/Users/sohail/Desktop/gulp-starter-csstricks/node_modules/orchestrator/index.js:134:8)                         
    at /usr/local/lib/node_modules/gulp/bin/gulp.js:129:20                                                                                     
    at _combinedTickCallback (internal/process/next_tick.js:67:7)                                                                              
    at process._tickCallback (internal/process/next_tick.js:98:9)                                                                              
    at Module.runMain (module.js:592:11)                                                                                                       
    at run (bootstrap_node.js:394:7)                                                                                                           
    at startup (bootstrap_node.js:149:9)                                                                                                       
    at bootstrap_node.js:509:3

有人了解我在代码中遗漏了什么吗?

-谢谢 苏海尔

【问题讨论】:

    标签: ftp gulp sftp


    【解决方案1】:

    您必须查看此错误行: SyntaxError:JSON 中第 36 位的意外标记 $

    似乎 json 格式不好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-25
      • 2014-12-10
      • 1970-01-01
      相关资源
      最近更新 更多