我试图在同一个类的方法连接中调用方法测试。但我得到的只是“未捕获的类型错误:无法读取未定义的属性‘test’”。如何访问 sftp 回调中的任何变量?为什么会这样?
这是我的代码:
const SSH2 = require('ssh2').Client;
class SshClient {
constructor(host, username, password) {
this.host = host;
this.username = username;
this.password = password;
this.port = 22;
this.client = null;
}
test(testvar) {
console.log(testvar);
}
connect() {
this.client = new SSH2();
let client = this.client;
let username = this.username;
this.client.connect({
host: this.host,
port: this.port,
username: this.username,
password: this.password
});
this.client.on('ready', function() {
console.log('Client :: ready', client);
client.sftp(function(err, sftp) {
if (err) throw err;
sftp.readdir('/home/' + username, function(err, list) {
if …Run Code Online (Sandbox Code Playgroud)我正在制作一个应通过grpc连接到远程主机并从那里调用一些功能的Electron应用程序。
但是我一直收到以下错误:未捕获的错误:动态链接库(DLL)初始化例程失败。\?\ D:\ Projects \ demo-app \ node_modules \ grpc \ src \ node \ extension_binary \ grpc_node.node
我尝试过了:
将依赖项安装为 npm install --unsafe-perm
但没有任何效果。