React-native 开发常见错误记录(一)

1. 生成项目报错:

执行 react-native init AwesomeProject的时候,
创建完的项目里边只有package.jsonyarn-error.log

《React-native 开发常见错误记录(一)》

提示npm仓库里找不到文件,
后来发现在执行react-native init AwesomeProject 后启动了yarn add,
好像意识到是yarn的问题了,运行:

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

《React-native 开发常见错误记录(一)》

2. 启动报错:

《React-native 开发常见错误记录(一)》

我的解决办法:

  1. 关闭现有的进程、命令行;
  2. 运行 react-native link react-native-vector-icons;
  3. 运行 react-native start --reset-cache;
  4. 最后运行 react-native run-ios 重新启动;

3. 报错 No bundle URL present;

我的解决办法:

  1. 退出现有的进程、命令行;
  2. 执行 npm start;
  3. 执行 react-native run-ios;

4. React-native fetch请求报错 Network request failed (ios)

解决办法:

《React-native 开发常见错误记录(一)》

3. 真机运行常见错误

1. 报错信息:

Signing for “sMobile” requires a development team. Select a development team in the project editor.

Code signing is required for product type ‘Application’ in SDK ‘iOS 11.2’
解决:
1、首先确保你在xcode已登陆你的apple账号;

《React-native 开发常见错误记录(一)》

2、点击你已经导入的项目主文件夹

《React-native 开发常见错误记录(一)》

3、这一项与你的手机系统保持一致

《React-native 开发常见错误记录(一)》

4、点击运行按钮!

如果提示Build Success,并且连接手机后提示:Development cannot be enabled while your device is locked.

解决:
1、去手机:设置 –> 通用 –> 还原 –> 还原位置和隐私
2、拔掉数据线、退出Xcode,在重新打开xcode,在插入数据线提示是否信任的时候点击信任!
ok~

5.报错: react native fsevents unavailable (this watcher can only be used on Darwin)

解决办法:https://github.com/expo/expo/…

参考@Meekohi的解决办法。

原因是watchman版本过旧或者错误,重新安装了watchman再试一下就可以了。

npm r -g watchman
brew install watchman
    原文作者:guanghua
    原文地址: https://segmentfault.com/a/1190000014093430
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞