undefined 不是 expo React Native 项目中的对象 global.performance.now
我正在尝试使用 expo start 命令运行该应用程序。到目前为止一切都很好,但今天却显示成这样。
任何帮助将不胜感激! :)
这些是我的依赖项,
{
"dependencies": {
"@expo-google-fonts/manrope": "^0.2.0",
"@expo-google-fonts/roboto": "^0.2.2",
"@expo/react-native-action-sheet": "^3.12.0",
"@flyerhq/react-native-link-preview": "^1.6.0",
"@gorhom/bottom-sheet": "4",
"@react-native-async-storage/async-storage": "~1.15.0",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/hooks": "^2.8.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "7.1.3",
"@react-native-firebase/app": "^14.5.0",
"@react-native-firebase/messaging": "^14.5.0",
"@react-native-picker/picker": "2.2.1",
"@react-navigation/core": "^6.1.1",
"@react-navigation/material-top-tabs": "^6.0.6",
"@react-navigation/native": "^6.0.6",
"@react-navigation/native-stack": "^6.2.5",
"@react-navigation/stack": "^6.1.1",
"@stomp/stompjs": "^6.1.2",
"@stripe/stripe-react-native": "0.2.3",
"expo-linking": "~3.0.0",
"expo-media-library": "~14.0.0",
"expo-notifications": "~0.14.0",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.6",
"expo-web-browser": "~10.1.0",
"firebase": "^9.6.7",
"firebase-admin": "^10.0.0",,
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-actionsheet": "^2.4.2",
"react-native-bottomsheet-reanimated": "^0.1.1",
"react-native-gesture-handler": "~2.1.0",
"react-native-hold-menu": "^0.1.1",
"react-native-image-crop-picker": "^0.37.2",
"react-native-image-picker": "^4.7.0",
"react-native-image-resizer": "^1.4.5",
"react-native-image-viewing": "^0.2.1",
"react-native-ionicons": "^4.x",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-linear-gradient": "^2.5.6",
"react-native-link-preview": "^1.4.2",
"react-native-pager-view": "5.4.9",
"react-native-parsed-text": "^0.0.22",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "2.4.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "~3.10.1",
"react-native-sticky-parallax-header": "^0.4.1",
"react-native-svg": "12.1.1",
"react-native-svg-charts": "^5.4.0",
"react-native-tab-view": "^3.1.1",
"react-native-unimodules": "0.12.0",
"react-native-vector-icons": "^9.0.0",
"react-native-web": "0.17.1",
"react-native-webview": "11.15.0",
"react-navigation": "^4.4.4",
"rn-fetch-blob": "^0.12.0",
"socket.io-client": "^4.4.1",
"sockjs-client": "1.4.0",
"stompjs": "2.3.3",
"text-encoding": "^0.7.0",
"url": "^0.11.0",
"watchman": "^1.0.0"
}}
我尝试更改react-native-reanimated包的版本,但仍然无法找出问题。
I'm trying to run the app using the expo start command. It worked fine so far but today it's showing like this.
Any help would be greatly appreciated! :)
These are my dependencies
{
"dependencies": {
"@expo-google-fonts/manrope": "^0.2.0",
"@expo-google-fonts/roboto": "^0.2.2",
"@expo/react-native-action-sheet": "^3.12.0",
"@flyerhq/react-native-link-preview": "^1.6.0",
"@gorhom/bottom-sheet": "4",
"@react-native-async-storage/async-storage": "~1.15.0",
"@react-native-community/clipboard": "^1.5.1",
"@react-native-community/hooks": "^2.8.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "7.1.3",
"@react-native-firebase/app": "^14.5.0",
"@react-native-firebase/messaging": "^14.5.0",
"@react-native-picker/picker": "2.2.1",
"@react-navigation/core": "^6.1.1",
"@react-navigation/material-top-tabs": "^6.0.6",
"@react-navigation/native": "^6.0.6",
"@react-navigation/native-stack": "^6.2.5",
"@react-navigation/stack": "^6.1.1",
"@stomp/stompjs": "^6.1.2",
"@stripe/stripe-react-native": "0.2.3",
"expo-linking": "~3.0.0",
"expo-media-library": "~14.0.0",
"expo-notifications": "~0.14.0",
"expo-splash-screen": "~0.14.1",
"expo-status-bar": "~1.2.0",
"expo-updates": "~0.11.6",
"expo-web-browser": "~10.1.0",
"firebase": "^9.6.7",
"firebase-admin": "^10.0.0",,
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-actionsheet": "^2.4.2",
"react-native-bottomsheet-reanimated": "^0.1.1",
"react-native-gesture-handler": "~2.1.0",
"react-native-hold-menu": "^0.1.1",
"react-native-image-crop-picker": "^0.37.2",
"react-native-image-picker": "^4.7.0",
"react-native-image-resizer": "^1.4.5",
"react-native-image-viewing": "^0.2.1",
"react-native-ionicons": "^4.x",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-linear-gradient": "^2.5.6",
"react-native-link-preview": "^1.4.2",
"react-native-pager-view": "5.4.9",
"react-native-parsed-text": "^0.0.22",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "2.4.1",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "~3.10.1",
"react-native-sticky-parallax-header": "^0.4.1",
"react-native-svg": "12.1.1",
"react-native-svg-charts": "^5.4.0",
"react-native-tab-view": "^3.1.1",
"react-native-unimodules": "0.12.0",
"react-native-vector-icons": "^9.0.0",
"react-native-web": "0.17.1",
"react-native-webview": "11.15.0",
"react-navigation": "^4.4.4",
"rn-fetch-blob": "^0.12.0",
"socket.io-client": "^4.4.1",
"sockjs-client": "1.4.0",
"stompjs": "2.3.3",
"text-encoding": "^0.7.0",
"url": "^0.11.0",
"watchman": "^1.0.0"
}}
I've tried changing the versions of the react-native-reanimated package but still couldn't figure out the problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己最近也遇到了这个问题。我不完全确定为什么会发生这种情况,但您可以尝试通过反复试验找到根本原因。对我来说,我在
build
文件夹中全局查找了对global.performance.now
的所有引用,并在代码中注释掉了它们(它们都是 js 文件)来自build
文件夹中的node_modules
包)。当我尝试重新加载应用程序时,我会收到有关缺少引用或未定义变量的更详细消息(因为我评论了调用global.performance.now
的行)。就我而言,它最终位于react-native
包中,特别是在createPerformanceLogger.js
文件。有趣的是,我能够在包中找到实际设置此对象的另一个文件 这里。因此,作为临时解决方法,我在
createPerformanceLogger.js
import 语句中添加了require('../Core/setUpPerformance');
语句。这为我解决了这个问题。显然,这不太好,因为它需要更改构建文件。我所做的是添加一个构建后步骤,以便在每次构建后以编程方式执行此操作,以避免手动执行此操作(my安装程序也使用Kotlinjs
,因此我将其添加为我的gradle.build.kts
文件)。无论如何,YMMV 但以这种方式确定根本原因将帮助您同时解除障碍,直到找到更长期的解决方案。值得注意的是,我最终开始在我的
package.json
中使用react
+react-native
版本,现在是react-native
包甚至没有捆绑在我的build
输出中(我认为这很奇怪),但这意味着我不再需要解决方法。顺便说一句,如果您好奇,这是我的 使用react
和react-native
版本。I had this problem recently myself. I'm not entirely sure why this is happening but you can try to find the root cause by trial and error. For me, I did a global find of all references to
global.performance.now
in thebuild
folder and commented out all of them in the code (they were all js files fromnode_modules
packages in thebuild
folder). Once I tried to reload the app, I would get a more detailed message about a missing reference or undefined variable (since I commented the lines calling onglobal.performance.now
). In my case, it ended up being located in thereact-native
package, specifically in thecreatePerformanceLogger.js
file. What was interesting was that I was able to find another file in the package that actually sets up this object here.So, as a temporary workaround, I added a
require('../Core/setUpPerformance');
statement in thecreatePerformanceLogger.js
import statements. This fixed the issue for me. Obviously, this isn't pretty since it requires altering build files. What I did was add a post-build step to do this programmatically after every build in order to avoid doing this manually (my setup usesKotlinjs
as well, so I added it as a post assemble step in mygradle.build.kts
file). In any case, YMMV but determining the root cause this way will help unblock you in the meantime until finding a more long term solution.It's worth noting that I eventually started playing with
react
+react-native
versions in mypackage.json
and now thereact-native
package is not even bundled in mybuild
output (which I thought was strange), but it means that I no longer need the workaround. By the way, in case you're curious, here are myreact
andreact-native
versions used.