pirumpi / sftp-upload

Allow to upload the content of a folder to a remote server through SFT utilizing pure Javascript.
40 stars 21 forks source link

Problem deploying #27

Closed efraimdahl closed 1 year ago

efraimdahl commented 2 years ago

I have been using this package without any issues for months now, but suddenly am running into problems: Closely following the use in the Readme: `require('dotenv').config(); console.log("Starting upload") let SftpUpload = require('sftp-upload'), fs = require('fs');

var options = { host: process.env.FTP_HOST, username: process.env.FTP_UN, password: process.env.FTP_PW, path: './dist', remoteDir: process.env.FTP_PATH, dryRun: false, }

sftp = new SftpUpload(options);

sftp.on('error', function(err) { console.log(options) throw err; }) .on('uploading', function(progress) { console.log(options); console.log('Uploading', progress.file); console.log(progress.percent+'% completed'); }) .on('completed', function() { console.log('Upload Completed'); }) .upload();`

The following is the output in the console: `> node deploy-sftp.js

Starting upload node:buffer:323 throw new ERR_INVALID_ARG_TYPE( ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined at new NodeError (node:internal/errors:371:5) at Function.from (node:buffer:323:9) at new Buffer (node:buffer:279:17) at onNEWKEYS (D:\Misc Coding Projects\Cleveland Independants\cle-independents\node_modules\ssh2\lib\Connection.js:2282:29)
at Parser. (D:\Misc Coding Projects\Cleveland Independants\cle-independents\node_modules\ssh2\lib\Connection.js:123:5) at Parser.emit (node:events:526:28) at Parser.parsePacket (D:\Misc Coding Projects\Cleveland Independants\cle-independents\node_modules\ssh2\lib\Parser.js:468:12)
at Parser.execute (D:\Misc Coding Projects\Cleveland Independants\cle-independents\node_modules\ssh2\lib\Parser.js:249:14)
at Socket. (D:\Misc Coding Projects\Cleveland Independants\cle-independents\node_modules\ssh2\lib\Connection.js:523:18) at Socket.emit (node:events:526:28) { code: 'ERR_INVALID_ARG_TYPE' }`

Thank you so much for any suggestions, also awesome work maintaining this package!

Best,

Efraim

pirumpi commented 1 year ago

Were you able to fix the issue?