diff --git a/lib/index.js b/lib/index.js index 6942b7b..72d5454 100644 --- a/lib/index.js +++ b/lib/index.js @@ -47,7 +47,9 @@ function unloadplugin(pluginname, pluginpath) { const plugin = require.resolve(pluginpath) try { if (plugin && require.cache[plugin]) { - require.cache[plugin].exports.unload() + // `unload()` isn't exported sometimes, + // when plugin isn't properly loaded + require.cache[plugin].exports?.unload?.() delete plugins[pluginname] delete require.cache[plugin] }