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 (whatwg-fetch - npm).
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”.
Everything should now work like a charm.
Hope this helps
UP: expo@30.0.1 added whatwg-fetch@2.0.4 as dependency. Problem is gone
I use yarn. But yes, you can do it your way. Then verify in your package-lock.json (or yarn.lock for yarn user). You can go to node_modules/whatwg-fetch/package.json which version is installed. Is it working ?
In your screen, “whatwg-fetch” doesn’t show which version is installed. But it shows “whatwg-fetch” is required for “isomorphic-fetch”. You need to go “whatwg-fetch” on your package-lock.json. As you can see on top right of vscode, there are 4 results.
The error doesn’t depend on expo-cli. This is because when you start new expo project, there is no package-lock.json or yarn.lock. So last version of whatwg-fetch@3.0.0 is installed. And this version has been published a few days ago. I think for now expo still requires whatwg-fetch@2.0.4.
i ha ve the same problem… i have update expo 30 and i not have the whatwg-fetch@2.0.4. but i have the same problem. red screen and not find the self variable…
yes, i need add whatwg-fetch@2.0.4 in my package. but the expo 30 is so slow… the location api are very slow in ios and android… this two release 29 and 30 are very bad… i stay in 28 for now! thanks for the help
Running app with 30.0.1. Works until I install other dependencies like, expo-three, expo-graphics. Then I get the “Can’t Find Variable Self” again. Then whatwg-fetch@3.0.0 gets brought back in.
I have recently come across this problem. I did not use any “whatwg-fetch” module but still, there is an error regarding “appRegistry” and “variable self”ONLY IN PRODUCTION. In my case, it was with the import format of a library.I found this after hours of random testing. Hope someone finds this useful
I had imported nanoid as - const nanoGenerator = “require(“nanoid/generate”)” (similar to nodejs)
nanoid is not supported in react native and I replaced it with my own function
I think you should also watch for the import statements in case you came across the same error