首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >gulp sftp上的gulp sftp错误

gulp sftp上的gulp sftp错误
EN

Stack Overflow用户
提问于 2016-10-29 04:47:00
回答 1查看 883关注 0票数 1

我已经用gulp sftp设置了一个gulp任务,并尝试了两个站点来连接它,但没有成功。我已经用Filezilla尝试过这两种方法,而且都在连接中。

我的任务如下:

代码语言:javascript
复制
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'
            }));
    });

我得到的回应如下:

代码语言:javascript
复制
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文件中添加用户和pwd,并将任务更改为:

代码语言:javascript
复制
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'
        }));
}); 

我得到以下错误:

代码语言:javascript
复制
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

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

-thanks Sohail

EN

回答 1

Stack Overflow用户

发布于 2018-01-08 23:39:16

您必须检查此错误行: SyntaxError:意外的token $ in JSON中的位置36

在json中这似乎是一个错误的格式。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40312992

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档