Merge pull request #5571 from Tyriar/5341

Fix isNode detection when process module is used in webpack
This commit is contained in:
Daniel Imms
2026-01-03 14:25:33 -08:00
committed by GitHub
+4 -1
View File
@@ -14,7 +14,10 @@ interface INavigator {
declare const navigator: INavigator;
declare const process: unknown;
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any)) ? true : false;
// navigator.userAgent is also checked here because bundling with the process module can cause
// issues otherwise. Note that navigator exists in Node.js 21+ but the userAgent is
// "Node.js/<version>".
export const isNode = (typeof process !== 'undefined' && 'title' in (process as any) && (typeof navigator === 'undefined' || navigator.userAgent.startsWith('Node.js/'))) ? true : false;
const userAgent = (isNode) ? 'node' : navigator.userAgent;
const platform = (isNode) ? 'node' : navigator.platform;