node.jsherokunpmheroku-ci

Unable to add npm modules on Heroku in NodeJS app


I'm Hosting a NodeJS application on Heroku, It renames the file on sFTP server. Please find below my app.js code. if I remove ssh2-sftp-client npm modules, everything is working fine. but then I'm unable to do sFTP connection. I'm very new to Heroku as well as NodeJS. Can you please help me out on this. on Local everything is working file. I'm confused about how to add npm ssh2-sftp-client to Heroku to execute nodeJS code properly.

    let Client = require('ssh2-sftp-client');
let sftp = new Client();
sftp.connect({
  host: 'host',
  port: 'port',
  username: 'user',
  password: 'password'
}).then(() => {
     return sftp.rename('/After30/Sunil.txt','/After30/Sunil.csv')

}).then(() => {
  console.log('Closing SFTP');
   return sftp.end();

}).catch(err => {
  console.log(err, 'catch error');
});

Please find package.json file code,

    {
  "name": "jb-activity-template",
  "version": "1.0.0",
  "description": "Journey Builder Activity Template",
  "engines": {
    "node": "6.11.1"
  },
  "scripts": {
    "start": "node app.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/bhanuatsfdc/SFMC/journey-builder-activity-template.git"
  },
  "keywords": [
    "journey",
    "builder",
    "salesforce marketing cloud",
    "heroku"
  ],
  "author": "Devs United",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/bhanuatsfdc/SFMC/journey-builder-activity-template/issues"
  },
  "homepage": "https://github.com/bhanuatsfdc/SFMC/journey-builder-activity-template#readme",
  "dependencies": {
    "body-parser": "^1.18.2",
    "bower": "^1.8.0",
    "errorhandler": "^1.5.0",
    "express": "^4.15.4",
    "jsonwebtoken": "^8.0.1",
    "ssh2-sftp-client": "^5.0.1",
    "request": "^2.81.0",
    "require": "^2.4.20"
  }
}

Please find my app log snap, Heroku App Log


Solution

  • Started working after I changed node js engine version in package.json (Put latest version)