无法使用node-ssh进行连接

时间:2016-05-30 07:16:28

标签: javascript node.js ssh node-modules

我尝试使用node-ssh模块

在我的机器上运行一些命令

代码是

var node_ssh, ssh;

node_ssh = require('node-ssh');
ssh = new node_ssh();

ssh.connect({
  host: 'host',
  username: 'username',
  password: 'password'
}).then(function() {
  ssh.execCommand('ls', {cwd:'/root/softwares', stream:'both'}).then(function(result) {
    console.log('STDOUT: ' + result.stdout);
    console.log('STDERR: ' + result.stderr);
  });
});

但在执行此操作时我收到以下错误

D:\node_ssh_test\node_modules\node-ssh\node_modules\js-toolkit\dist\main.js:21
  promisified.prototype = callback.prototype;
                                  ^
TypeError: Cannot read property 'prototype' of undefined
    at promisify (D:\node_ssh_test\node_modules\node-ssh\node_modules\js-toolkit\dist\main.js:21:35)
    at Object.<anonymous> (D:\node_ssh_test\node_modules\node-ssh\Dist\SSH.js:18:39)

    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\node_ssh_test\test.js:3:12)
    at Module._compile (module.js:456:26)

0 个答案:

没有答案