gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

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

Open erikandershed opened 6 years ago

erikandershed commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

Any update on this?

erikandershed commented 6 years ago

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 commented 6 years ago

@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

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

erikandershed commented 6 years ago

Yes it works! Thanks!

mahathun commented 6 years ago

Np. Glad i could help. 😊

RaoufMounif commented 3 years ago

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 commented 3 years ago

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 ssh2@0.5.5, 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.)