From 28e7f08dd7a78a61a40f7c9f90ed30a94b167a35 Mon Sep 17 00:00:00 2001 From: Steven Sherry Date: Wed, 6 Mar 2024 10:03:06 -0600 Subject: [PATCH] fix(cli): Attempt to verify non-cjs modules exist if cjs resolution fails (#7310) (#7313) --- 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 1fb84678f..914ca7029 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; } }