Skip to content

Commit b522e25

Browse files
authored
Merge pull request #5571 from Tyriar/5341
Fix isNode detection when process module is used in webpack
2 parents 4182f22 + d7850af commit b522e25

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/common/Platform.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ interface INavigator {
1414
declare const navigator: INavigator;
1515
declare const process: unknown;
1616

17-
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any)) ? true : false;
17+
// navigator.userAgent is also checked here because bundling with the process module can cause
18+
// issues otherwise. Note that navigator exists in Node.js 21+ but the userAgent is
19+
// "Node.js/<version>".
20+
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any) && (typeof navigator === 'undefined' || navigator.userAgent.startsWith('Node.js/'))) ? true : false;
1821
const userAgent = (isNode) ? 'node' : navigator.userAgent;
1922
const platform = (isNode) ? 'node' : navigator.platform;
2023

0 commit comments

Comments
 (0)