diff --git a/src/compiler/tsbuildPublic.ts b/src/compiler/tsbuildPublic.ts index 3f0e366be3afe..e01810b5d714e 100644 --- a/src/compiler/tsbuildPublic.ts +++ b/src/compiler/tsbuildPublic.ts @@ -874,7 +874,7 @@ namespace ts { ); state.lastCachedPackageJsonLookups.set(projectPath, state.moduleResolutionCache && map( state.moduleResolutionCache.getPackageJsonInfoCache().entries(), - ([path, data]) => ([state.host.realpath ? toPath(state, state.host.realpath(path)) : path, data] as const) + ([path, data]) => ([state.host.realpath && data ? toPath(state, state.host.realpath(path)) : path, data] as const) )); if (state.watch) {