【发布时间】:2018-04-13 09:16:43
【问题描述】:
我是 ReactNative 开发的新手,我正在尝试将 NativeBase 2.2.0 导入我的项目。我按照这个指示 Getting started
步骤:
$react-native init MyProject
$cd MyProject
$react-native run-android
在手机上安装成功后,我尝试安装 NativeBase
$npm install native-base --save
native-base@2.3.3 安装后 \MyProject e_modules\native-base 节点 addEjectScript.js
┌────────────────────────────────────────────── ────────────────────────────── ────────────┐ │ NativeBase 2.0 安装成功! │ │ 运行
node node_modules/native-base/ejectTheme.js复制主题机密变量。 │ │ 前往 docs for 有关如何更改主题的详细信息。 │ └────────────────────────────────────────────────── ────────────────────────── ──────────────┘ npm 通知创建了一个锁文件为 package-lock.json。你 应该提交这个fnpm WARN native-base@2.3.3 需要一个 react@>=16.0.0-alpha.3 但未安装。您必须自己安装对等依赖项。 npm WARN native-base@2.3.3 需要一个 react-native@>=0.46.0 但是 没有安装。您必须自己安装对等依赖项。 npm 警告 native-base-shoutem-theme@0.2.1 需要 react-native@>=0 0 的对等方 但没有安装。您必须自己安装对等依赖项。 npm WARN native-base-shoutem-theme@0.2.1 需要一个peer react@>=16.0.0-a .3 但没有安装。您必须安装对等 自己依赖。
- native-base@2.3.3 在 78.962 秒内增加了 22 个包,删除了 625 个包并更新了 91 个包
但是当我转到Install Peer Dependencies 步骤时,我得到了错误
$react-native link
命令
link无法识别。确保您已运行npm install你在一个 react-native 项目中。
那我试试:
$npm install react
npm WARN react-native@0.49.5 requires a peer of react@16.0.0-beta.5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
react@16.0.0 added 115 packages, removed 15 packages and updated 1 package in 20.176s
$npm install react-native
npm WARN deprecated connect@2.30.2: connect 2.x series is deprecated
npm WARN react-native@0.49.5 requires a peer of react@16.0.0-beta.5 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ react-native@0.49.5
added 115 packages, removed 15 packages and updated 1 package in 189.374s
$react-native link
Scanning folders for symlinks in ..\ReactNative\MyAsset\node_modules (40ms)
rnpm-install info Linking assets to ios project
rnpm-install info Linking assets to android project
rnpm-install info Assets have been successfully linked to your project
我在尝试安装应用时遇到错误。
$react-native run-android
React packager ready.
Loading dependency graph, done.
Bundling `index.js` [development, non-minified] 0.0% (0/418), failed.
error: bundling failed: Error: Cannot find module 'AccessibilityInfo' (While processing preset: "MyProject\\node_modules\\react-native\\Libraries\\react-native\\react-native-implementation.js")
at Function.Module._resolveFilename (module.js:527:15)
at Function.Module._load (module.js:476:23)
at Module.require (module.js:568:17)
at require (internal/module.js:11:18)
at Object.get AccessibilityInfo [as AccessibilityInfo] (MyProject\node_modules\react-native\Libraries\react-native\react-native-implementation.js:19:36)
at MyProject\node_modules\babel-core\node_modules\lodash\_baseClone.js:145:23
at arrayEach (MyProject\node_modules\babel-core\node_modules\lodash\_arrayEach.js:15:9)
at baseClone (MyProject\node_modules\babel-core\node_modules\lodash\_baseClone.js:142:3)
at cloneDeepWith (MyProject\node_modules\babel-core\node_modules\lodash\cloneDeepWith.js:37:10)
环境
- 节点--版本
v6.11.5
- react-native --version
react-native-cli:2.0.1
react-native: n/a - 不在 React Native 项目目录中
- npm --version
5.5.1
我在这里做错了什么或遗漏了什么吗?
任何人都可以帮忙吗?
谢谢。
【问题讨论】:
-
任何人都可以提供帮助。我仍然坚持这一点。气死我了orz配置环境好像很复杂吧?
标签: react-native react-native-android react-native-ios native-base