1

I'm trying to use from a nx project (using @nrwl/node), within a nodeJS API, the ssh2 plugin.

Here's my module:

export const datasetTranferModule = ({ username, password }) => {

  var connSettings = {
    host: "192.168.1.14",
    port: 22,
    username,
    password
    // You can use a key file too, read the ssh2 documentation
  };
  var SSHClient = require("ssh2").Client;
  // do something with SSHClient
  return;
};

By changing the default webpack behavior, I didn't manage to get it working:

module.exports = (config, context) => {
  const WorkerPlugin = require('worker-plugin')
  return {
    ...config,
    node: {
      process: true,
      global: true
    },
    plugins: [
      new WorkerPlugin({
        plugins: [
          // A string here will copy the named plugin from your configuration:
          'ssh2',
          
          // Or you can specify a plugin directly, only applied to Worker code:
        ]
      })
    ]
  };
};

Is it fine to do it within a worker? If so how to import ssh from the worker?

dbrrt
  • 2,275
  • 4
  • 18
  • 35

0 Answers0