【问题标题】:How to import NativeBase 2.2.0 to ReactNative project?如何将 Native Base 2.2.0 导入 React Native 项目?
【发布时间】: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。你 应该提交这个f

npm 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


【解决方案1】:

native-base@2.3.3 在 78.962s 内增加了 22 个包,删除了 625 个包并更新了 91 个包

这很奇怪。我正在使用native-base,但以前没有看到过。

再次安装原生基础后运行npm install

如果它不起作用,请运行 npm install reactnpm install react-native

它应该可以工作。

【讨论】:

  • 我按照你说的做了同样的步骤,安装成功了。但是当我尝试'react-native link'时我仍然得到错误。我已经坚持了几天了。
  • 检查你的 node_modules/react/package.json 和 node_modules/react-native/package.json 并告诉我这些包的版本
  • 在“react-native 链接”工作之后,我尝试了“npm install react”和“npm install react-native”。但是当我尝试“react-native run-android”时,我得到了错误 ==> { Bundling index.js [development, non-minified] 0.0% (0/418), failed。错误:捆绑失败:错误:找不到模块“AccessibilityInfo”(处理预设时:“MyProject\\node_modules\\react-native\\Libraries\\react-nat‌​ive\\react-native-im‌​plementation.js” ) } .我编辑了我的问题。可以看看吗谢谢
  • 安装 react-native 后尝试react-native upgrade 然后react-native run-android
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-23
相关资源
最近更新 更多