无法安装react-native-vector-icons@6.0.1 in react native 0.55.4?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (1)
  • 关注 (0)
  • 查看 (171)

我试图安装react-native-vector-icons版本6.0.1 in react native 0.55.4但是每当我尝试在应用程序错误中使用矢量图标语法和图标时都会收到错误,如下所示。我想使用字体真棒5个图标。我应该使用哪个版本的本机来安装这些图标。有没有我可以使用的其他库。

Metro Bundler ready.

Loading dependency graph, done.
error: bundling failed: Error: Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "E:\\RN\\newproject\\node_modules\\react-native-vector-icons"
    at E:\RN\newproject\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (E:\RN\newproject\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (E:\RN\newproject\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
 BUNDLE  [android, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░ 98.8% (479/482), failed.

我的package.json

{
  "name": "newproject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-vector-icons": "^5.0.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "babel-preset-react-native": "4.0.1",
    "jest": "23.6.0",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }
}
提问于
用户回答回答于

试图通过安装package.json文件来使用矢量图标。没工作。我正在使用带有以下依赖关系的react-native-vector-icons。

的package.json

  "dependencies": {
    "axios": "^0.18.0",
    "expo": "^30.0.1",
    "hashmap": "^2.3.0",
    "react": "16.3.1",
    "react-native": "0.55.4",
    "react-native-vector-icons": "^6.0.2",
    "react-navigation": "^2.16.0"
  }

从此链接创建一个新的反应应用程序。希望能为你效劳。

扫码关注云+社区

领取腾讯云代金券