Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: file.pipe is not a function #78

Open
ashlinaronin opened this issue Dec 31, 2017 · 21 comments
Open

TypeError: file.pipe is not a function #78

ashlinaronin opened this issue Dec 31, 2017 · 21 comments

Comments

@ashlinaronin
Copy link

Just a few days ago I started seeing this error in my Travis CI builds using gulp-sftp:

TypeError: file.pipe is not a function
    at /Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/gulp-sftp/index.js:275:22
    at Object.async.whilst (/Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/gulp-sftp/node_modules/async/lib/async.js:683:13)
    at /Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/gulp-sftp/node_modules/async/lib/async.js:679:23
    at /Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/gulp-sftp/index.js:255:21
    at SFTP._parse (/Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/ssh2/lib/SFTP/SFTPv3.js:1093:13)
    at ChannelStream.<anonymous> (/Users/ashlinaronin/Local Sites/portland-naacp/app/public/wp-content/themes/portland-naacp/node_modules/ssh2/lib/SFTP/SFTPv3.js:72:10)
    at emitOne (events.js:96:13)
    at ChannelStream.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at ChannelStream.Readable.push (_stream_readable.js:134:10)

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.

@sshehata
Copy link

sshehata commented Jan 5, 2018

+1

@alexander-mart
Copy link

alexander-mart commented Jan 9, 2018

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

@Dan503
Copy link

Dan503 commented Jan 9, 2018

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 :/

@Dan503
Copy link

Dan503 commented Jan 9, 2018

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

@Dan503
Copy link

Dan503 commented Jan 10, 2018

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.

@ashlinaronin
Copy link
Author

Nice, @Dan503! Submit as a PR to this project?

@Dan503
Copy link

Dan503 commented Jan 10, 2018

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.

ashlinaronin added a commit to naacp-portland/gulp-sftp that referenced this issue Jan 10, 2018
@furic-zhao
Copy link

非常感谢!!!

@Mindgames
Copy link

@Dan503 Amazing!, thx

@costacode
Copy link

@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?

@costacode
Copy link

@Dan503 Found it. Yeah, reference is done on the actual gulpfile, where I now call my local index.js, instead of the npm version.

@Dan503
Copy link

Dan503 commented Mar 26, 2018

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.

@Dan503
Copy link

Dan503 commented Mar 26, 2018

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.

@costacode
Copy link

Great, did exactly that. Thanks for the reply!

thomasfrobieter added a commit to webksde/gulp-sftp that referenced this issue Jul 1, 2018
@unlocomqx
Copy link

As @Dan503 has a working fork, you can simply install it like this
npm i -D git+https://git@github.com/webksde/gulp-sftp

aaaton pushed a commit to aaaton/gulp-gcloud-publish that referenced this issue Jan 14, 2019
@smemainLi
Copy link

问题解决了!感谢~

@lyconear
Copy link

my problem is solved, thx!!! it is worked!!

@Dan503
Copy link

Dan503 commented May 25, 2019

It's best not to post comments like "thanks" and "+1".

You can show appreciation through using the reaction emojis on the individual comments.

maxbarbieri added a commit to maxbarbieri/gulp-sftp that referenced this issue Jul 2, 2019
@vladaman
Copy link

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

@unlocomqx
Copy link

@vladaman
Try this
#78 (comment)
it's a working fork by webksde

@cngbinho
Copy link

# 78 (comentário) solved my problem thanks +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests