freshy icon indicating copy to clipboard operation
freshy copied to clipboard

About unloading modules

Open anhldbk opened this issue 8 years ago • 1 comments

Would you please tell me what will happen with the unloaded module?

In the following image, I expected variable lodash will be undefined or null after the associated module is unloaded. But it's not.

screenshot from 2016-05-05 21-25-32

anhldbk avatar May 05 '16 14:05 anhldbk

That won't happen, because you are holding a reference in your lodash variable. .unload('lodash') will remove the module and its dependencies from require.cache. So the next time you do var lodash2 = require('lodash') it will be different from lodash != lodash2.

osukaa avatar Nov 30 '17 15:11 osukaa