我正在尝试@nrwl/node
在 nodeJS API 中使用 nx 项目(使用)中的 ssh2 插件。
这是我的模块:
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;
};
通过更改默认的 webpack 行为,我没有设法让它工作:
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:
]
})
]
};
};
在工人内部做这件事好吗?如果是这样,如何从工人那里导入 ssh?