From d0476dd91e6cf18ff8882f475e6a03b2b8970bb4 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Fri, 21 Oct 2022 13:22:01 -0400 Subject: [PATCH] Use `require.resolve` to find electron package Fixes #38 --- src/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index a1a4066..acb656b 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -511,8 +511,8 @@ export function externalizeDepsPlugin(options: ExternalOptions = {}): Plugin | n function getElectronMainVer(root: string): string { let mainVer = process.env.ELECTRON_MAIN_VER || '' if (!mainVer) { - const electronModulePath = path.resolve(root, 'node_modules', 'electron') - const pkg = path.join(electronModulePath, 'package.json') + const electronModulePath = require.resolve('electron') + const pkg = path.join(electronModulePath, '../package.json') if (fs.existsSync(pkg)) { const require = createRequire(import.meta.url) const version = require(pkg).version