From 663e7b383be0ceee1d23b929ceb6374d00faf011 Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Tue, 5 Mar 2024 12:58:14 -0600 Subject: [PATCH] fix(cli): Attempt to verify non-cjs modules exist if cjs resolution fails (#7310) --- cli/src/util/node.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/src/util/node.ts b/cli/src/util/node.ts index 1fb84678fa..914ca7029c 100644 --- a/cli/src/util/node.ts +++ b/cli/src/util/node.ts @@ -1,4 +1,5 @@ import { readFileSync } from '@ionic/utils-fs'; +import { existsSync } from 'fs'; import { resolve } from 'path'; import type typescript from 'typescript'; @@ -56,6 +57,10 @@ export function resolveNode( try { return require.resolve(pathSegments.join('/'), { paths: [root] }); } catch (e) { + const path = [root, 'node_modules', ...pathSegments].join('/'); + if (existsSync(path)) { + return path; + } return null; } }