From fc38e7f557523c31cde947f417de7785cdd0b1f2 Mon Sep 17 00:00:00 2001 From: Joseph Lee Date: Fri, 7 Apr 2023 12:29:21 +0900 Subject: [PATCH] feat: Support Yarn PnP --- packages/api/core/src/api/start.ts | 2 ++ packages/utils/core-utils/src/electron-version.ts | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/packages/api/core/src/api/start.ts b/packages/api/core/src/api/start.ts index 673ffc5e9e..c3ce82332c 100644 --- a/packages/api/core/src/api/start.ts +++ b/packages/api/core/src/api/start.ts @@ -153,6 +153,8 @@ export default async ({ } as NodeJS.ProcessEnv, }; + delete spawnOpts.env.NODE_OPTIONS; + if (runAsNode) { spawnOpts.env.ELECTRON_RUN_AS_NODE = 'true'; } else { diff --git a/packages/utils/core-utils/src/electron-version.ts b/packages/utils/core-utils/src/electron-version.ts index 2709800a98..5f490157eb 100644 --- a/packages/utils/core-utils/src/electron-version.ts +++ b/packages/utils/core-utils/src/electron-version.ts @@ -66,6 +66,13 @@ function getElectronModuleName(packageJSON: PackageJSONWithDeps): string { async function getElectronPackageJSONPath(dir: string, packageName: string): Promise { const nodeModulesPath = await determineNodeModulesPath(dir, packageName); if (!nodeModulesPath) { + try { + // Yarn PnP + // eslint-disable-next-line node/no-missing-require + return require.resolve('electron/package.json'); + } catch (e) { + // Ignore + } throw new PackageNotFoundError(packageName, dir); }