freshy
freshy copied to clipboard
About unloading modules
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.
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
.