[英]require(“ssh2”) without specific object in node.js
What does it mean if you require('ssh2')
in Node.js without a specific object (eg require('ssh2').Client
)? 如果您在Node.js中没有特定对象(例如require('ssh2').Client
)的require('ssh2')
,那意味着什么? I have some code I am trying to understand and I am just learning Node.js. 我有一些我想理解的代码,而我只是在学习Node.js。 It's used like this: 它的用法如下:
var ssh2Connection = require("ssh2");
...
var conn new ssh2Connection();
conn.on("ready", function() {
...
});
Requiring require("ssh2") is essentially returning the value defined by this line 要求require(“ ssh2”)本质上是返回此行定义的值
module.exports = 'hello'
Requiring require("ssh2").Client is essentially returning the value defined by this line 要求require(“ ssh2”)。客户实际上是在返回此行定义的值
module.exports.Client = 'hello'
This is used to extend multiple objects to a module. 这用于将多个对象扩展到一个模块。 Could be something like 可能像
module.exports.Client1 = 'hello1'
module.exports.Client2 = 'hello2'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.