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

Jav*_*ana 0 react-native

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

关于堆栈的这个,这个以及许多其他问题在这里溢出但是我无法让它工作

我第一次使用了

react-native init myapp
Run Code Online (Sandbox Code Playgroud)

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

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

import Icon from 'react-native-vector-icons/FontAwesome';
Run Code Online (Sandbox Code Playgroud)

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

在Android上

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
Run Code Online (Sandbox Code Playgroud)

在iOS上

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
Run Code Online (Sandbox Code Playgroud)

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

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>
Run Code Online (Sandbox Code Playgroud)

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

Jav*_*ana 7

我终于找到了解决方案

这只发生在react-native版本0.52.0中.它试图找到的文件确实声明了该模块.关于文件搜索顺序的某些内容必须随最新版本而更改.

试试这个

rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json
Run Code Online (Sandbox Code Playgroud)

链接1,链接2