美文网首页
使用react-native-vector-icons遇到的一些

使用react-native-vector-icons遇到的一些

作者: 萤火虫叔叔 | 来源:发表于2018-05-04 09:47 被阅读988次

作者注:这篇文章会不断更新哦~

1. bug

按照官网的步骤配置好了之后,仍然报错如下:

error: bundling failed: Error: While trying to resolve module `react-native-vector-icons/` 
from file `/Users/huangying/Documents/ynwt-git/rn/yywl-ios/app/containers/course/CourseDetail.js`, 
the package `/Users/huangying/Documents/ynwt-git/rn/yywl-ios/node_modules/react-native/local-cli/core/__fixtures__/files/package.json` 
was successfully found. However, this package itself specifies a `main` module field that could not be resolved
 (`/Users/huangying/Documents/ynwt-git/rn/yywl-ios/node_modules/react-native/local-cli/core/__fixtures__/files/index.js`.
 Indeed, none of these files exist:

官网ios使用react-native-vector-icons使用步骤:


ios使用react-native-vector-icons的步骤

2.解决方案

方案1:

在react-native-vector-icons的issues里,看到大家有同样的bug,这是由于react-native高版本引起的,所以把react-native的版本从0.52.2降到0.51.0就解决了。

方案2:

删掉
删掉文件node_modules/react-native/local-cli/core/__fixtures__/files/package.json
在项目根目录下执行以下命令即可

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

注意:删除之后记得重启server,也是就把运行ios弹出来的那个终端关掉

方案3:

在项目根目录新建文件rn-cli.config.js,文件中的内容如下:

const blacklist = require('metro/src/blacklist')

module.exports = {
  getTransformModulePath () {
    return require.resolve('react-native-typescript-transformer')
  },
  getSourceExts () {
    return ['ts', 'tsx']
  },
  getBlacklistRE () {
  return blacklist([/react-native\/local-cli\/core\/__fixtures__.*/])
  },
}

欢迎加我微信,拉进群交流哦!


微信二维码

相关文章

网友评论

      本文标题:使用react-native-vector-icons遇到的一些

      本文链接:https://www.haomeiwen.com/subject/kairrftx.html