SFTP from MongoDB Trigger Functions not working

I am using this code to test my connection to a SFTP host in a MongoDB Trigger.
I installed the dependency ‘node-ssh’. This code works fine when I run using the node command, oustside the trigger, in my cmd. Please advise.

exports = function() {
  const { NodeSSH } = require('node-ssh');
  
  const ssh = new NodeSSH();

// Configure connection details
const sshConfig = {
  host: '100.xx.xx.xxx',
  port: '22',
  username: 'myuser',
  password: 'pwd'
};

// Establish SSH connection
ssh.connect(sshConfig)
  .then(() => {
    console.log('Connected to the remote server');
  })
  .catch((error) => {
    console.error('Error connecting to the remote server:', error);
  });

};

When I am running it as a MongoDB Trigger it throws error:

failed to execute source for 'node_modules/node-ssh/lib/cjs/index.js': FunctionError: failed to execute source for 'node_modules/ssh2/lib/index.js': FunctionError: failed to execute source for 'node_modules/ssh2/lib/agent.js': FunctionError: failed to compile source for module './protocol/keyParser.js': SyntaxError: node_modules/ssh2/lib/protocol/keyParser.js: Line 149:61 Unexpected token ILLEGAL (and 4 more errors)
	at require (native)
	at node_modules/ssh2/lib/agent.js:57:17(89)
	at require (native)
	at node_modules/ssh2/lib/index.js:14:16(17)
	at require (native)
	at node_modules/node-ssh/lib/cjs/index.js:75:30(140)
	at require (native)
	at exports (function.js:2:23(6))
	at apply (native)
	at function_wrapper.js:2:18(17)
	at <eval>:8:8(2)
	at <eval>:2:15(7)
	at native