React native 在React Native中记录当前目录/文件名

React native 在React Native中记录当前目录/文件名,react-native,React Native,我想知道是否有办法在React Native中记录当前文件名或目录。与NodeJS使用\uuuu filename和\uuu dirname的方式类似,这是不可能的,因为所有的源代码都被捆绑到一个大文件中,然后提供一个源代码映射,以便您可以在原始结构中调试它。 通过在代码中的某个地方调用此代码段,您可以看到: console.log(new Error().stack); 在常规javascript中,您将获得包含文件和行号的整个跟踪,但在react native中,您会得到如下结果: Err

我想知道是否有办法在React Native中记录当前文件名或目录。与NodeJS使用
\uuuu filename
\uuu dirname

的方式类似,这是不可能的,因为所有的源代码都被捆绑到一个大文件中,然后提供一个源代码映射,以便您可以在原始结构中调试它。
通过在代码中的某个地方调用此代码段,您可以看到:

console.log(new Error().stack);
在常规javascript中,您将获得包含文件和行号的整个跟踪,但在react native中,您会得到如下结果:

Error
at Login (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:83009:9)
at instantiate (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5712:18)
at new Login (eval at proxyClass (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5730:16), <anonymous>:4:17)
at ReactCompositeComponentWrapper._constructComponentWithoutOwner (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22051:19)
at ReactCompositeComponentWrapper._constructComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22033:13)
at ReactCompositeComponentWrapper.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:21952:15)
at Object.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)
at ReactCompositeComponentWrapper.performInitialMount (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22134:28)
at ReactCompositeComponentWrapper.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22015:13)
at Object.mountComponent (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)"
错误
登录时(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:83009:9)
在实例化时(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5712:18)
在新登录时(评估proxyClass(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:5730:16), :4:17)
在ReactCompositeComponentWrapper.\u constructComponentWithoutOwner(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22051:19)
在ReactCompositeComponentWrapper.\u constructComponent(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22033:13)
在ReactCompositeComponentWrapper.mountComponent处(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:21952:15)
在Object.mountComponent(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)
在ReactCompositeComponentWrapper.PerformitialMount处(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22134:28)
在ReactCompositeComponentWrapper.mountComponent处(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:22015:13)
在Object.mountComponent(http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=true&minify=false:20425:29)"

这表明真正的文件已经消失。

如果我通过chrome运行react native with remote debug,我会在每个console.log的最右边找到文件和行号。有没有办法在代码中访问这些信息?即使只是在调试时。