希望这是一个简单的问题,但我在谷歌搜索中找不到任何东西。在模拟器上运行(使用任何构建类型)都能完美地工作。然而,使用任何构建类型(调试或发布)连接设备在运行时会出现以下问题(应用程序可以成功构建):

我的package.json有以下dep:
"dependencies": {
"@redux-offline/redux-offline": "2.4.0",
"babel-plugin-transform-remove-console": "6.9.4",
"buffer": "5.2.0",
"crypto-js": "3.1.9-1",
"lodash": "4.17.10",
"react": "16.3.1",
"react-native": "0.54.4",
"react-native-fast-image": "4.0.14",
"react-native-firebase": "4.3.8",
"react-native-fs": "2.10.14",
"react-native-maps": "0.21.0",
"react-native-maps-super-cluster": "1.4.1",
"react-native-navigation": "1.1.471",
"react-native-svg": "6.4.1",
"react-native-tab-view": "1.0.2",
"react-redux": "5.0.7",
"redux": "4.0.0",
"redux-logger": "3.0.6",
"redux-thunk": "2.3.0",
"whatwg-url": "6.5.0"
},
"devDependencies": {
"babel-eslint": "^8.2.3",
"babel-jest": "23.0.1",
"babel-preset-flow": "6.23.0",
"babel-preset-react-native": "4.0.0",
"eslint": "4.19.1",
"eslint-config-airbnb": "16.1.0",
"eslint-plugin-flowtype": "2.49.3",
"eslint-plugin-import": "2.12.0",
"eslint-plugin-jsx-a11y": "6.0.3",
"eslint-plugin-react": "7.9.1",
"flow-bin": "0.65.0",
"husky": "0.14.3",
"jest": "23.1.0",
"lint-staged": "7.1.3",
"prettier": "1.13.4",
"react-native-schemes-manager": "1.0.4",
"react-test-renderer": "16.3.0-alpha.1"
},我的.babelrc具有以下特性:
{
"presets": ["react-native", "flow"],
"env": {
"production": {
"plugins": ["transform-remove-console"]
}
}
}我正在使用react-native-schemes-manager来构建一个基础应用的风格。此配置在package.json中如下所示:
"xcodeSchemes": {
"Debug": [
"FakeAppNameDebug"
],
"Release": [
"FakeAppNameRelease"
]
}所有这些都不能解释为什么它在模拟器上工作得很好,但在设备上运行时却想要发脾气。有什么想法吗?
发布于 2019-02-21 23:27:17
我也有同样的问题,这就是我发现的:
RN is executed in two different environments (V8 or JavaScriptCore)中的JS,这取决于您如何运行它。例如,在我的例子中,应用程序在iOS模拟器上运行正常,无论有没有远程js调试器;在Android模拟器上,只有在远程调试器打开的情况下才能工作,并且在没有远程调试器的情况下抛出错误;在真正的Android设备上抛出错误。考虑到JSC comes in two different versions (supplied by iOS or packaged in RN app for Android),我的结论是iOS的JSC和V8确实理解target.new,而Android打包的JSC不理解(顺便说一句,Babel也不理解)。
这就是new.target失败的原因,这取决于您在哪里运行它。
现在,这个bug是从哪里来的:我使用this method来查找culrpit,并在node_modules/whatwg-url/lib/URL.js中的whatwg-url包中找到它
return iface.setup(Object.create(new.target.prototype), args);tl;dr;有几种可能的解决方案:
whatwg-url这可能只是一个临时的解决方案,因为有更多的东西是原始的JSC不支持的(例如,代理或符号,不能简单地转换或polyfilled).new.target实例更改为new . target (显然所有引擎都支持它),只是为了检查newTarget是否是你唯一的问题。在我的例子中,它似乎也是不受支持的代理(我使用的是mobx v5),所以仅仅摆脱whatwg-url并不能解决我的问题。https://stackoverflow.com/questions/52567922
复制相似问题