【发布时间】:2017-06-07 18:00:28
【问题描述】:
我正在使用react-native 框架来开发我的安卓应用程序。我想使用react-native-material-design 库来制作具有更多功能的Toolbar。
我将此库安装在我的项目使用以下命令的当前目录中:-
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
PS:我在 Windows 7 机器上,找不到执行命令的方法。我见过这个The development server returned response error code: 500 in react-native,但它对我没有帮助。
谁能帮我解决这个问题。提前致谢。
【问题讨论】:
-
您是否尝试在本地而不是全局安装
react-native-material-design? -
@EmilioRodriguez 是的,它起作用了 谢谢我想知道如果我在全球范围内安装 npm 包会有什么不同的原因?您能否回答这个问题,以便我可以将其标记为已接受答案
标签: android react-native react-native-android