node.js require() cache - possible to invalidate?

后端 未结 17 1643
我寻月下人不归
我寻月下人不归 2020-11-22 06:52

From the node.js documentation:

Modules are cached after the first time they are loaded. This means (among other things) that every call to require(\'

17条回答
  •  醉话见心
    2020-11-22 07:49

    If you always want to reload your module, you could add this function:

    function requireUncached(module) {
        delete require.cache[require.resolve(module)];
        return require(module);
    }
    

    and then use requireUncached('./myModule') instead of require.

提交回复
热议问题