File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,10 @@ interface INavigator {
1414declare const navigator : INavigator ;
1515declare 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 ;
1821const userAgent = ( isNode ) ? 'node' : navigator . userAgent ;
1922const platform = ( isNode ) ? 'node' : navigator . platform ;
2023
You can’t perform that action at this time.
0 commit comments