javascript - Is it possible to override a module in CJS or NodeJS? -
i importing module in application using 'require'. , want change functionality of module in js file , starting step, if require module, changed chings should affect. possible achieve this? not exact this.
//module1.js module.exports = function(p,q) { retrun p+q; } //app.js var change = require(./module1);// 'require'd here modify,actually there no dependency var dependency = require(./dependency1) //modifying module1 functionality // module.exports = function() {return p-q;} //dependency1.js var use1 = require(./module1) log(use1(8,3))// should result in '5' enter code here
any ais highly appreciable. thankyou
Comments
Post a Comment