reactjs - ReferenceError:找不到变量:文档
问题描述
我正在使用 react native 创建一个简单的移动应用程序。该项目在模拟器上运行良好,直到我添加了 redux。我正在使用 redux 进行登录和注销;它实际上只是一个减速器和操作文件,用于在登录时使用注册用户名设置 authedUser,并在注销时设置为 null。如果我在网络浏览器上运行它,它可以正常工作,但不能在 ios/android 模拟器上运行。通过在模拟器上运行时react-native run-android
出现上述错误。通过 expo 运行它时,我得到: Invariant Violation: “main” has not been registered。
这是
完全丢失的错误的屏幕截图。有什么建议么?
package.json 内容:
{
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@react-native-community/async-storage": "^1.11.0",
"@react-native-community/masked-view": "0.1.10",
"@react-navigation/bottom-tabs": "^5.7.3",
"@react-navigation/native": "^5.7.2",
"@reduxjs/toolkit": "^1.4.0",
"expo": "~38.0.1",
"expo-updates": "~0.2.10",
"react": "~16.11.0",
"react-dom": "^16.13.1",
"react-native": "~0.62.2",
"react-native-elements": "^2.0.4",
"react-native-gesture-handler": "~1.6.0",
"react-native-qrcode-svg": "^6.0.6",
"react-native-reanimated": "~1.9.0",
"react-native-safe-area-context": "~3.0.7",
"react-native-screens": "~2.9.0",
"react-native-svg": "^12.1.0",
"react-native-unimodules": "~0.10.1",
"react-native-web": "~0.11.7",
"react-redux": "^7.2.1",
"redux": "^4.0.5"
},
"devDependencies": {
"@babel/core": "~7.9.0",
"babel-jest": "~25.2.6",
"jest": "~25.2.6",
"react-test-renderer": "~16.11.0"
},
"jest": {
"preset": "react-native"
},
"private": true
}
解决方案
当您在调试模式下在模拟器中运行您的应用程序时,由于调试器是 chrome devtools,它会知道文档的实例并且不会产生任何错误。基本上,您使用的是 webapp 在您的 react native 应用程序中使用的一些 npm 模块。你能列出你的 package.json 文件的内容吗?
推荐阅读
- node.js - js中的密码问题
- c - stdatomic.h 的名称是否与在句点之前映射到八个有效字符的(潜在)限制相矛盾?
- java - 从 route53 托管区域请求记录以检索所有记录时如何执行批处理
- tree - 获取目录中所有文件的列表(如“树”),但使用它们的“标题”属性
- r - R:如何在将 tidyverse 连接到多个内核时使其安静。(降价)
- java - 屏幕阅读器宣布导航抽屉中的项目数量不正确
- python - 在 Lambda 层中使用 VGG preprocess_input 以及 Dense 和 keras.backend.clear_session() 时出现 KERAS 错误
- javascript - 在 Nodejs OAuth2 上与谷歌注册时出现异步等待错误
- python - 在不同光量下检测颜色斑点中心的可靠方法?
- javascript - PayPal Checkout 订阅按钮只显示两种支付方式,enableFunding 无效