我是ReactNative开发的新手,正在尝试将NativeBase 2.2.0导入到我的项目中。我遵循这个指示入门
步骤:
$react-native init MyProject
$cd MyProject
$react-native run-android
在我的手机上成功安装应用程序后,我尝试安装NativeBase
$npm install native-base --save
native-base@2.3.3postinstall\MyProject e_modules\native basenode addEjectScript.js
┌────────────────────────────────────────────────────────────────────────────────────────┐ │NativeBase 2.0已成功安装!│ │运行
node node_modules/native-base/ejectTheme.js
以复制主题配置变量。│ │前往文档关于如何更改主题的详细信息。│└────────────────────────────────────────────────────────────────────────────────────────┘npm通知创建了一个名为package-lock.json的锁定文件应该为提交npm警告native-base@2.3.3需要一个react的peer@>=16.0-α3但未安装。您必须自己安装对等依赖项。npm警告native-base@2.3.3需要react native@>=0.46.0的对等端,但是未安装。您必须自己安装对等依赖项。npm警告native-base-shoutem-theme@0.2.1需要react native的对等@>=0 0但是没有安装。您必须自己安装对等依赖项。npm警告native-base-shoutem-theme@0.2.1需要的对等react@>=16.0-a.3,但未安装。您必须安装peer依赖关系。
- native-base@2.3.3在78.962秒内增加了22个软件包,删除了625个软件包并更新了91个软件包
但当我进入Install Peer Dependencies
步骤时,我得到了错误
$react-native link
无法识别命令
link
。确保已运行npm install
并且您在一个react原生项目中。
然后我尝试:
$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_modulesfsevents):
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_modulesfsevents):
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 ..ReactNativeMyAssetnode_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] (MyProjectnode_modulesreact-nativeLibrariesreact-nativereact-native-implementation.js:19:36)
at MyProjectnode_modulesbabel-corenode_moduleslodash_baseClone.js:145:23
at arrayEach (MyProjectnode_modulesbabel-corenode_moduleslodash_arrayEach.js:15:9)
at baseClone (MyProjectnode_modulesbabel-corenode_moduleslodash_baseClone.js:142:3)
at cloneDeepWith (MyProjectnode_modulesbabel-corenode_moduleslodashcloneDeepWith.js:37:10)
环境
-node-版本
v6.11.5
-react native-版本
react native cli:2.0.1
react native:n/a-不在react native项目目录内
-npm-版本
我是做错了什么还是遗漏了什么?有人能帮忙吗
谢谢。
native-base@2.3.3在78.962s 中增加了22个包裹,删除了625个包裹,更新了91个包裹
这很奇怪。我正在与原生基地合作,但以前没有看到这一点。
再次安装本机基础后运行npm install
。
如果不起作用,则运行npm install react
和npm install react-native
它应该起作用。