我正在使用Vinyl-ftp进行部署,当我尝试连接FileZilla或Total Commander时一切正常,但是当我尝试wulh Gulp任务时我得到了奇怪的错误,我没有看到差异,这是我的Gulp任务和错误消息
gulp.task('ftp-test-connection', function () {
var conn = ftp.create({
host: 'hostname',
user: 'user',
password: 'password',
parallel: 10,
log: gutil.log
});
var globs = [
'./styles/**/*{css,png,jpg,gif,ttf,woff,eof,svg,woff2}',
'./images/**',
'./views/**',
'./scripts/vendor.scripts.min.js',
'./dist/index.html',
'./dist_test/main.scripts.min.js',
'./dist_test/web.config'
];
return gulp.src(globs, { base: '.', buffer: false })
.pipe(gulpIf('dist/index.html', rename({ dirname: '' })))
.pipe(gulpIf('dist/web.config', rename({ dirname: '' })))
.pipe(gulpIf('dist_test/main.scripts.min.js', rename({ dirname: '/scripts' })))
.pipe(conn.newer('/site/wwwroot'))
.pipe(conn.dest('/site/wwwroot'));
});
这是我的错误 **
[11:31:59] ERROR Error: User cannot log in.
at makeError (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:1067:13)
at Parser.<anonymous> (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:113:25)
at emitTwo (events.js:87:13)
at Parser.emit (events.js:172:7)
at Parser._write (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\parser.js:59:10)
at doWrite (_stream_writable.js:292:12)
at writeOrBuffer (_stream_writable.js:278:5)
at Parser.Writable.write (_stream_writable.js:207:11)
at Socket.ondata (C:\node_modules\vinyl-ftp\node_modules\ftp\lib\connection.js:273:20)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:146:16)
at Socket.Readable.push (_stream_readable.js:110:10)
at TCP.onread (net.js:523:20) (530)
Process terminated with code 1.
**
答案 0 :(得分:2)
我遇到了与“vinyl-gulp”和Azure App Services(a.k.a. Azure网站)相同的问题。
在我的情况下,问题是由Azure FTP用户名中包含的“\”字符引起的。 我只需要加倍“\”(例如:“someuser \ $ someuser”)来解决问题。
我希望它有所帮助...
微米。