Android 开发服务器在react native中返回响应错误代码:500
我正在使用Android 开发服务器在react native中返回响应错误代码:500,android,react-native,react-native-android,Android,React Native,React Native Android,我正在使用react native框架开发我的android应用程序。我想使用react native material design库制作工具栏,并提供更多功能 我已将此库安装在项目使用以下命令的当前目录中:- E:\>npm i react-native-material-design -g --save C:\Users\ch-e00925\AppData\Roaming\npm `-- react-native-material-design@0.3.7 +-- react-n
react native
框架开发我的android应用程序。我想使用react native material design
库制作工具栏
,并提供更多功能
我已将此库安装在项目使用以下命令的当前目录中:-
E:\>npm i react-native-material-design -g --save
C:\Users\ch-e00925\AppData\Roaming\npm
`-- react-native-material-design@0.3.7
+-- react-native-material-design-styles@0.2.6 (git+https://github.com/react-n
ative-material-design/react-native-material-design-styles.git#bdc029c1a1c83ff563
d10868be38b8aed1e9989b)
`-- react-native-vector-icons@2.1.0
+-- lodash@4.17.4
`-- yargs@4.8.1
+-- cliui@3.2.0
| +-- strip-ansi@3.0.1
| | `-- ansi-regex@2.1.1
| `-- wrap-ansi@2.1.0
+-- decamelize@1.2.0
+-- get-caller-file@1.0.2
+-- lodash.assign@4.2.0
+-- os-locale@1.4.0
| `-- lcid@1.0.0
| `-- invert-kv@1.0.0
+-- read-pkg-up@1.0.1
| +-- find-up@1.1.2
| | +-- path-exists@2.1.0
| | `-- pinkie-promise@2.0.1
| | `-- pinkie@2.0.4
| `-- read-pkg@1.1.0
| +-- load-json-file@1.1.0
| | +-- graceful-fs@4.1.11
| | +-- parse-json@2.2.0
| | | `-- error-ex@1.3.0
| | | `-- is-arrayish@0.2.1
| | +-- pify@2.3.0
| | `-- strip-bom@2.0.0
| | `-- is-utf8@0.2.1
| +-- normalize-package-data@2.3.5
| | +-- hosted-git-info@2.1.5
| | +-- is-builtin-module@1.0.0
| | | `-- builtin-modules@1.1.1
| | +-- semver@5.3.0
| | `-- validate-npm-package-license@3.0.1
| | +-- spdx-correct@1.0.2
| | | `-- spdx-license-ids@1.2.2
| | `-- spdx-expression-parse@1.0.4
| `-- path-type@1.1.0
+-- require-directory@2.1.1
+-- require-main-filename@1.0.1
+-- set-blocking@2.0.0
+-- string-width@1.0.2
| +-- code-point-at@1.1.0
| `-- is-fullwidth-code-point@1.0.0
| `-- number-is-nan@1.0.1
+-- which-module@1.0.0
+-- window-size@0.2.0
+-- y18n@3.2.1
`-- yargs-parser@2.4.1
`-- camelcase@3.0.0
E:\>
在此之后,我在运行应用程序时遇到一个问题,可能是库未成功安装
E:\Myntra>react-native start
Scanning 557 folders for symlinks in E:\Myntra\node_modules (114ms)
┌────────────────────────────────────────────────────────────────────────────┐
│ Running packager on port 8081. │
│ │
│ Keep this packager running while developing on any JS projects. Feel │
│ free to close this tab and run your own packager instance if you │
│ prefer. │
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
Looking for JS files in
E:\Myntra
[01/23/2017, 13:36:07] <START> Initializing Packager
[01/23/2017, 13:36:08] HMR Server listening on /hot
React packager ready.
[01/23/2017, 13:36:12] <START> Requesting bundle
bundle_url: /index.android.bundle?platform=androi
d&dev=true&hot=true&minify=false
[01/23/2017, 13:36:40] <START> Building Haste Map
[01/23/2017, 13:36:40] <END> Building Haste Map (141ms)
[01/23/2017, 13:36:40] <END> Initializing Packager (33314ms)
[01/23/2017, 13:36:40] <START> Transforming files
transformed 584/607 (96%)(node:6316) UnhandledPromiseRejectionWarning: Unhandled
promise rejection (rejection id: 605): UnableToResolveError: Unable to resolve
module react-native-material-design-styles from E:\Myntra\node_modules\react-nat
ive-material-design\lib\config.js: Module does not exist in the module map or in
these directories:
E:\Myntra\node_modules\react-native-material-design\node_modules
, E:\Myntra\node_modules
This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
1. Clear watchman watches: `watchman watch-del-all`.
2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
3. Reset packager cache: `rm -fr $TMPDIR/react-*` or `npm start -- --reset-cac
he`.
[01/23/2017, 13:54:09] <START> Requesting bundle
bundle_url: /index.android.bundle?platform=androi
d&dev=true&hot=true&minify=false
E:\Myntra>react native start
扫描557个文件夹以查找E:\Myntra\node_模块中的符号链接(114ms)
┌────────────────────────────────────────────────────────────────────────────┐
│ 在端口8081上运行分装机。│
│ │
│ 在任何JS项目上开发时保持此打包程序运行。感觉│
│ 如果您愿意,可以自由关闭此选项卡并运行自己的packager实例│
│ 更喜欢│
│ │
│ https://github.com/facebook/react-native │
│ │
└────────────────────────────────────────────────────────────────────────────┘
在中查找JS文件
E:\Myntra
[01/23/2017,13:36:07]初始化分装机
[01/23/2017,13:36:08]HMR服务器正在侦听/热
准备好分装机。
[01/23/2017,13:36:12]请求捆绑
bundle\u url:/index.android.bundle?platform=androi
d&dev=true&hot=true&minify=false
[01/23/2017,13:36:40]建筑加速图
[01/23/2017,13:36:40]建筑加速图(141ms)
[01/23/2017,13:36:40]初始化分装机(33314ms)
[01/23/2017,13:36:40]正在转换文件
已转换584/607(96%)(节点:6316)未处理Promisejection警告:未处理
承诺拒绝(拒绝id:605):无法解决错误:无法解决
来自E:\Myntra\node\u modules\react nat的模块react原生材质设计样式
ive material design\lib\config.js:模块地图或中不存在模块
这些目录:
E:\Myntra\node\u模块\react原生材料设计\node\u模块
,E:\Myntra\node\u模块
这可能与https://github.com/facebook/react-native/issues/4968
要解决此问题,请尝试以下操作:
1.清除守望人手表:`watchman watch del all`。
2.删除'node_modules'文件夹:'rm-rf node_modules&&npm install`。
3.重置打包机缓存:`rm-fr$TMPDIR/react-*`或`npm start--Reset cac
他`。
[01/23/2017,13:54:09]请求捆绑
bundle\u url:/index.android.bundle?platform=androi
d&dev=true&hot=true&minify=false
PS:我在Windows7机器上,找不到执行命令的方法。我已经看到了这一点,但它并没有帮助我
谁能帮我解决这个问题。提前谢谢
尝试在本地而不是全局安装
react native material design
看起来react native material设计依赖于react native的捆绑程序不会打包的react native material设计样式,因为它的父模块是全局模块。当您未指定
.js
文件的正确路径时,有时会出现此错误
与键入正确的路径类似,而不是键入路径:
var WeatherProject = require('./Main/WeatherProject');
键入了错误的路径(大写、拼写错误、特殊符号):
babel预设反应本机
制造此问题。在项目根目录中运行以下命令:
$纱线移除巴别塔预设反应本机
$
纱线添加巴别塔预设反应-native@2.1.0
您导入的JavaScript文件的名称可能与任何预定义库/组件的名称相同。例如,从已创建的文件夹app/components导入View.js
import View from './app/components/View'
上述语句将产生错误。因此,通过将文件名更改为Interface.js
import Interface from './app/components/Interface'
现在,代码可以很好地运行了出现此错误的原因之一是因为我两次导入了“react native”库
import { View, Text, ActivityIndicator } from "react-native";
import { View, Text, ActivityIndicator, TouchableOpacity, StyleSheet } from "react-native";
我不知道这是否真的会导致此问题,但删除导入的冗余行为我解决了此问题。首先执行,获取版本号:
C:\WINDOWS\system32>react-native -v react-native-cli
2.0.1反应本机:0.56.0
然后我卸载了react native:
C:\WINDOWS\system32>npm uninstall -g react-native-cli
npm install react-native@0.55.4
在3.999s中删除了41个软件包
然后我安装了react native:
C:\WINDOWS\system32>npm uninstall -g react-native-cli
npm install react-native@0.55.4
然后我安装了react native cli:
npm install -g react-native-cli@1.2.0
然后使用此安装创建react本机项目:
react-native init --version="0.55.4" myprojectname
如果您使用的是react native version:56.0,则将其降级为54版。它对我有效我的端口8081也有同样的问题,请将其更改为8082。因为它已经被其他服务使用了,这是我的工作 首先运行包服务器: 大宗报价 打开另一个命令提示符,像往常一样启动Android应用程序: 完成后,现在重写用于以下操作的tcp端口: 请参见adb tcp隧道列表: 现在,您应该看到如下消息:
检查您的应用程序,它将运行 对于使用
存储
或顶级组件的用户。如果您删除了一个,那么请确保它没有被导入到其他任何地方
在我的例子中,我删除了一个正在顶级导入的存储。作为React native字段的新成员,我曾经多次遇到这个错误,我也一直都是这样
react-native run-android
adb reverse tcp:8081 tcp:8082
adb reverse --list
(reverse) tcp:8081 tcp:8082
npm install react-navigation --save