如何覆盖Node中的其他模块方法

时间:2013-09-13 09:57:16

标签: node.js

module1.js

// here how can i overide the module2 someMethod()

module2.js

exports.someMethod=function() {}

1 个答案:

答案 0 :(得分:0)

require('./module2').someMethod = function myOwnMethod () {
  // Not too hard was it?
};