@@ -26,7 +26,16 @@ const {
2626 *
2727 * @note A naive search on disk might yield false positives so we also try to
2828 * use the stack trace to find it. This currently works in Node (V8) and Bun
29- * (JSC).
29+ * (JSC), but not on Windows for some reason. On Windows, this causes 'xpath' to
30+ * crash:
31+ *
32+ * [xmldom error] invalid doc source
33+ * #[line:0,col:undefined]
34+ *
35+ * D:\~\node_modules\xpath\xpath.js:1787
36+ * if (firstNode.nodeType === 9) {
37+ * ^
38+ * TypeError: Cannot read properties of undefined (reading 'nodeType')
3039 *
3140 * @returns {string }
3241 */
@@ -35,7 +44,7 @@ function findReactNativeConfig(fs = nodefs) {
3544 // stack[1] holds where this function was called
3645 // stack[2] holds the file we're interested in
3746 const position = 2 ;
38- if ( position < Error . stackTraceLimit ) {
47+ if ( position < Error . stackTraceLimit && process . platform !== "win32" ) {
3948 const orig_prepareStackTrace = Error . prepareStackTrace ;
4049 let stack ;
4150 try {
@@ -46,9 +55,12 @@ function findReactNativeConfig(fs = nodefs) {
4655 }
4756
4857 if ( Array . isArray ( stack ) ) {
49- const file = stack [ position ] ?. getFileName ( ) ;
50- if ( path . basename ( file ) . startsWith ( "react-native.config." ) ) {
51- return file ;
58+ const callsite = stack [ position ] ;
59+ if ( callsite && typeof callsite === "object" && "getFileName" in callsite ) {
60+ const file = callsite . getFileName ( ) ;
61+ if ( path . basename ( file ) . startsWith ( "react-native.config." ) ) {
62+ return file ;
63+ }
5264 }
5365 }
5466 }
0 commit comments