如何安装react-native-vector-icons?

时间:2018-01-29 17:33:22

标签: react-native

我真的尝试了所有可以找到的资源

ThisThis以及有关堆栈溢出的其他许多问题 但是我无法让它工作

我第一次使用

import Icon from 'react-native-vector-icons/FontAwesome';

启动项目并按照其github页面上的说明安装react-native-vector-icons的命令

我已经像这样导入了FontAwesome系列

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

Body:
{"type":"InternalError","errors":[],"message":"Metro Bundler has encountered an internal error, please check your terminal error output for more details"}
processBundleResult
    BundleDownloader.java:242
access$100
    BundleDownloader.java:41
onResponse
    BundleDownloader.java:208
execute
    RealCall.java:135
run
    NamedRunnable.java:32
runWorker
    ThreadPoolExecutor.java:1112
run
    ThreadPoolExecutor.java:587
run
    Thread.java:818

但是,当我运行应用程序时,我在android和ios上都会出现此错误

在Android上

Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Metro Bundler has encountered an internal error, please check your terminal error output for more details (null))

__38-[RCTCxxBridge loadSource:onProgress:]_block_invoke.242
    RCTCxxBridge.mm:419
___ZL36attemptAsynchronousLoadOfBundleAtURLP5NSURLU13block_pointerFvP18RCTLoadingProgressEU13block_pointerFvP7NSErrorP9RCTSourceE_block_invoke.118
__80-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]_block_invoke
-[RCTMultipartStreamReader emitChunk:headers:callback:done:]
-[RCTMultipartStreamReader readAllPartsWithCompletionCallback:progressCallback:]
-[RCTMultipartDataTask URLSession:streamTask:didBecomeInputStream:outputStream:]
__88-[NSURLSession delegate_streamTask:didBecomeInputStream:outputStream:completionHandler:]_block_invoke
__NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
-[NSBlockOperation main]
-[__NSOperationInternal _start:]
_dispatch_client_callout
_dispatch_block_invoke_direct
_dispatch_client_callout
_dispatch_block_invoke_direct
dispatch_block_perform
__NSOQSchedule_f
_dispatch_client_callout
_dispatch_continuation_pop
_dispatch_async_redirect_invoke
_dispatch_root_queue_drain
_dispatch_worker_thread3
_pthread_wqthread
start_wqthread

在iOS上

deltaUrlToBlobUrl.js:31 GET http://localhost:8081/index.delta?platform=android&dev=true&minify=false 500 (Internal Server Error)

DeltaPatcher.js:58 Uncaught (in promise) Error: DeltaPatcher should receive a fresh Delta when being initialized
at DeltaPatcher.applyDelta (DeltaPatcher.js:58)
at deltaUrlToBlobUrl (deltaUrlToBlobUrl.js:34)
at <anonymous>

在调试控制台上我得到了这个错误

{{1}}

如果能让它发挥作用我会很高兴的。提前谢谢。

2 个答案:

答案 0 :(得分:7)

我终于找到了解决方案

仅在react-native版本0.52.0中发生 它试图找到的文件确实声明了该模块。关于文件搜索顺序的一些事情必须随着最近的版本而改变。

试试这个

rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json

Link 1Link 2

答案 1 :(得分:0)

使用npm,您可以轻松地安装它。请在根文件夹中遵循以下公共条件:

* npm install react-native-vector-icons
* react-native link