react native can't find variable: self

 从git新down的代码 npm install 安装依赖,react-native run-android后服务启动100%无任何错误,可app启动后爆红了react native can't find variable: self,

1、按理说can't find variable:*是因为缺少某种引用,沿着这个思路去解决发现self没有用的地方,好吧百度

2、普遍说的是修改node_modules/isomorphic-fetch/fetch-npm-browserify.js文件为

var globalObject = typeof self === "undefined" ? global : self;

module.exports = globalObject.fetch.bind(globalObject);

//module.exports = fetch;

经测试问题依旧

3、在stackoverflow上无意间看到这样一篇文章https://stackoverflow.com/questions/52269560/react-native-expo-cant-find-variable-self/52271297#52271297

For users creating new project with expo-cli or XDE, you will get red screen “Can’t Find Variable Self” after your first “yarn” or “npm install”. This is because of new “whatwg-fetch” 3.0.0 published yesterday (https://www.npmjs.com/package/whatwg-fetch 23). So you just need to force dependency to previous version: "whatwg-fetch": "^2.0.4" It means put it in package.json as “dependency”. Manually, with “yarn add whatwg-fetch@2.0.4.” Or with “npm add whatwg-fetch@2.0.4”.

修改版本号2.0.4 成功进入应用 ,哎... 原来是whatwg-fetch3.0.0搞得鬼

thinks:

https://stackoverflow.com/questions/52269560/react-native-expo-cant-find-variable-self/52271297#52271297

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值