Open ashlinaronin opened 6 years ago
+1
This error was started after update Gulp to version 4.0.0
from 3.9.1
TypeError: file.pipe is not a function
at /foobar/node_modules/gulp-sftp/index.js:275:22
Specifically it started occurring when Gulp 4 updated from gulp-4.0-alpha.2
to gulp-4.0-alpha.3
.
I've had issues with other components as well due to this change (browserify and gulp-modernizr broke for me as well). Unfortunatly it doesn't seem possible to download gulp-4.0-alpha.2
through npm so we're kinda stuck :/
From one of the Gulp core contributors:
we removed the pipe method that existed on a Vinyl object because the API was very bad and did not do what people expected. Plugins now need to be handling null/streaming/buffer contents specifically instead of that opaque file.pipe API
vinyl-ftp has a similar looking ftp upload file. I was able to get it working after taking a bit of inspiration from this file: https://github.com/morris/vinyl-ftp/blob/master/lib/ftp.js
First, create a local copy of the gulp-sftp index.js file and save it into your version control.
Find this line: file.pipe(stream); // start upload
it should be on line 284 of index.js
Replace it with this:
// start upload
if ( file.isStream() ) {
file.contents.pipe( stream );
} else if ( file.isBuffer() ) {
stream.end( file.contents );
}
Now reference your new version of gulp-sftp instead of the npm version and it should magically start working again.
Nice, @Dan503! Submit as a PR to this project?
I might do it later. I doubt it would do much good though. The owner hasn't made any alterations to this thing in over 2 whole years.
非常感谢!!!
@Dan503 Amazing!, thx
@Dan503 I made changes on the index.js and it certainly fixes the Gulp 4 compatibility. Got a question about the reference to the new version of gulp-sftp (instead of the npm version). Where do you make that change?
@Dan503 Found it. Yeah, reference is done on the actual gulpfile, where I now call my local index.js, instead of the npm version.
First, create a local copy of the gulp-sftp index.js file and save it into your version control.
@costacode the change is made to the copy you made of the gulp-sftp index.js file.
the reference to the new version of gulp-sftp (instead of the npm version). Where do you make that change?
Oh right, yeah you add that reference to the gulp file you are using gulp-sftp in.
So instead of
import sftp from "gulp-sftp"
You would have
import sftp from "./gulp-sftp-copy"
Or something like that. The path would be different depending on where you placed the file.
Great, did exactly that. Thanks for the reply!
As @Dan503 has a working fork, you can simply install it like this
npm i -D git+https://git@github.com/webksde/gulp-sftp
问题解决了!感谢~
my problem is solved, thx!!! it is worked!!
It's best not to post comments like "thanks" and "+1".
You can show appreciation through using the reaction emojis on the individual comments.
Is there any fix for this? I am still experiencing same issue.
gulp-sftp version: 0.1.5
gulp --version
CLI version: 2.2.0
Local version: 4.0.0
@vladaman Try this https://github.com/gtg092x/gulp-sftp/issues/78#issuecomment-448987310 it's a working fork by webksde
# 78 (comentário) solved my problem thanks +1
Just a few days ago I started seeing this error in my Travis CI builds using gulp-sftp:
Everything was still working locally for me, so I tried clearing out my node_modules and re-installed them, and now I see this same error locally as well.
Given that the gulp-sftp plugin itself hasn't been updated in two years, it appears there is a new issue with one of its dependencies. Has anyone else seen this? I'm having difficulty tracking down the exact source of the problem.