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

Don't work to upload through gulp-sftp #82

Open
erikandershed opened this issue Aug 13, 2018 · 10 comments
Open

Don't work to upload through gulp-sftp #82

erikandershed opened this issue Aug 13, 2018 · 10 comments

Comments

@erikandershed
Copy link

I can't find a fix for this problem. I get this error (throw new TypeError(kFromErrorMsg);) it started a couple months back . I Can't upload any fils to SFTP see my settings and respons:

var sftp = require('gulp-sftp');

gulp.task('upload-PHP', function() {

   // Upload all files
    gulp.src(
        [build_public+'/**/*',
        '!'+build_public+'/version.json',
        '!'+build_public+'/video/**/*',
        '!'+build_public+'/data_en.json',
        '!'+build_public+'/data_sv.json',
        '!'+build_public+'/icons/**/*'
    ])
        .pipe(sftp({
            host: 'XXX',
            user: 'XXX',
            pass: 'XXX',
            port: 2222,
            remotePath: './wp-content/themes/test'
        }));

});
gulp upload-PHP
[08:33:39] Starting 'upload'...
[08:33:39] Starting 'upload-PHP'...
[08:33:39] Finished 'upload-PHP' after 9.67 ms
[08:33:39] Finished 'upload' after 11 ms
[08:33:39] Authenticating with password.
buffer.js:262
  throw new TypeError(kFromErrorMsg);
  ^

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
    at fromObject (buffer.js:262:9)
    at Function.Buffer.from (buffer.js:101:10)
    at new Buffer (buffer.js:80:17)
    at onNEWKEYS (/Users/erik/Desktop/Erik/code/dev/app/node_modules/ssh2/lib/Connection.js:2366:29)
    at Parser.<anonymous> (/Users/erik/Desktop/Erik/code/dev/app/node_modules/ssh2/lib/Connection.js:129:5)
    at emitNone (events.js:86:13)
    at Parser.emit (events.js:185:7)
    at Parser.parsePacket (/Users/erik/Desktop/Erik/code/dev/app/node_modules/ssh2/lib/Parser.js:468:12)
    at Parser.execute (/Users/erik/Desktop/Erik/code/dev/app/node_modules/ssh2/lib/Parser.js:249:14)
    at Socket.<anonymous> (/Users/erik/Desktop/Erik/code/dev/app/node_modules/ssh2/lib/Connection.js:536:18)
@mahathun
Copy link

was going to do a PR but, it seems this issue has been fixed on some pull request, but i guess, its not been updated in the npm, i just updated the ssh2 version number to "ssh2": "~0.5.5" and did a npm install again within the library and works.

@erikandershed
Copy link
Author

I did remove gulp and reinstalled all, also updated ssh2 to 0.6.1. After this I get an other errow

eriks-mbp:app erik$ gulp -v
[15:42:00] CLI version 2.0.1
[15:42:00] Local version 3.9.1
[15:41:14] Starting 'default'...
[15:41:14] Authenticating with password.
buffer.js:207
    throw new ERR_INVALID_ARG_TYPE(
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined
    at Function.from (buffer.js:207:11)
    at new Buffer (buffer.js:182:17)
    at onNEWKEYS (/Users/erik/Desktop/Erik/code/dev/app/node_modules/gulp-sftp/node_modules/ssh2/lib/Connection.js:2366:29)
    at Parser.<anonymous> (/Users/erik/Desktop/Erik/code/dev/app/node_modules/gulp-sftp/node_modules/ssh2/lib/Connection.js:129:5)
    at Parser.emit (events.js:182:13)
    at Parser.parsePacket (/Users/erik/Desktop/Erik/code/dev/app/node_modules/gulp-sftp/node_modules/ssh2/lib/Parser.js:468:12)
    at Parser.execute (/Users/erik/Desktop/Erik/code/dev/app/node_modules/gulp-sftp/node_modules/ssh2/lib/Parser.js:249:14)
    at Socket.<anonymous> (/Users/erik/Desktop/Erik/code/dev/app/node_modules/gulp-sftp/node_modules/ssh2/lib/Connection.js:536:18)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)

@erikandershed
Copy link
Author

the same problem is when I try Gulp 4

$ gulp -v
[16:27:13] CLI version 2.0.1
[16:27:13] Local version 4.0.0-alpha.3

@erik-spacebetween
Copy link

Any update on this?

@erikandershed
Copy link
Author

It seems that I can't update the gulp-sftp to 0.1.6 where the update dependencies is for "ssh2": "~0.5.5". Can you please helt me.

@mahathun
Copy link

mahathun commented Sep 5, 2018

@erikandershed do you get any errors, did you try the method i told you.

  1. remove the node folder "rm -rf node_modules"
  2. reinstall all the packages npm install
  3. goto the gulp-sftp folder inside the node_modules cd node_modules/gulp-sftp
  4. open it in a text editor("subl .") and change the ssh2 package version to "~0.5.5"

before
screen shot 2018-09-05 at 9 11 36 pm

after
screen shot 2018-09-05 at 9 11 36 pm

  1. go back up 2 steps. "cd .." , "cd .." and do a "npm install" again.

@erikandershed
Copy link
Author

Yes it works! Thanks!

@mahathun
Copy link

mahathun commented Sep 7, 2018

Np. Glad i could help. 😊

@RaoufMounif
Copy link

Is there any way to not manipulate the folders manually, in my case am using a DevOps pipeline and I don't have an enough rights on the remote server folders to modifiy node_modules .

So ho I can update the SSH2 version of Gulp-SFTP from package.json ?

@mahathun
Copy link

Is there any way to not manipulate the folders manually, in my case am using a DevOps pipeline and I don't have an enough rights on the remote server folders to modifiy node_modules .

So ho I can update the SSH2 version of Gulp-SFTP from package.json ?

You able to modify the dev pipeline, if so, i think, after doing the npm install, if you add another step with something like npm remove ssh2 && npm install [email protected], it should work ( haven't tested this, but it should work.)

if you can't modify the pipeline for some reason, i guess, the way would be to, download the gulp-sftp source and then publish it to npm as a custom package. then you can use that custom package within the package.json :) (this would be the better way of doing it compared to the first method.)

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

4 participants