module1.js
module.exports = function (input, input2) {
return "exported";
};
modulegetter.js
var module1 = require('/Users/Aakarsh/Desktop/Node/ToDo/playground/module1.js');
console.log(module1);
这个输出是什么: [function]
我希望它像在 module1.js
类中那样输出 "exported"
。我能做什么?
额外:
当我有这个时,在 modulegetter.js
中,
var f = function (input, input2) {
return "exp";
};
console.log(f("f", "f"));
它按要求输出 exp
,但为什么它不能与 module.exports 一起工作?
最佳答案
您需要实际调用该函数(带或不带参数):
console.log(module1());
关于javascript - NodeJS中的Module.exports,输出函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41336276/