From 7e008c8d4478fb1884ed25f3c912fba6a83aab93 Mon Sep 17 00:00:00 2001 From: Eric Greene Date: Thu, 16 Aug 2018 22:25:02 -0400 Subject: [PATCH] fix require.main for use with Node.js mjs modules --- lib/appenders/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/appenders/index.js b/lib/appenders/index.js index d7408b8..cd7ad96 100644 --- a/lib/appenders/index.js +++ b/lib/appenders/index.js @@ -34,7 +34,7 @@ const tryLoading = (modulePath, config) => { const loadAppenderModule = (type, config) => coreAppenders.get(type) || tryLoading(`./${type}`, config) || tryLoading(type, config) || - tryLoading(path.join(path.dirname(require.main.filename), type), config) || + (require.main && tryLoading(path.join(path.dirname(require.main.filename), type), config)) || tryLoading(path.join(process.cwd(), type), config); const createAppender = (name, config) => {