Can't Find Variable Self

Hi there,

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 :wink:

UP: expo@30.0.1 added whatwg-fetch@2.0.4 as dependency. Problem is gone :wink:


Stupid question - is this done in package.json followed by an npm update? I can’t seem to downgrade the package…

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 ?

I was being a bit thick, a fresh npm install after downgrading the package fixed my problem.

Thanks for the investigation - you’ve got me up and running again :smile: :

1 Like

Can you please elaborate ‘downgrading package’? I am facing the similar issue

I have done as you said but still when i do npm install it is getting updated to 3.0.0

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.

I inserted the dependency in my package.json with:

“whatwg-fetch”: “^2.0.4”

Then I deleted my package-lock.json, my node_modules folder and re-ran npm install and everything worked again :slight_smile:


Yes you have to put it in package.json. Manually, with “yarn add whatwg-fetch@2.0.4.” or with “npm add whatwg-fetch@2.0.4”

1 Like

thanks, I was struggling with this issue for a couple of days yet

1 Like

You are amazing! Thanks for the fix.

The error is still there when using expo-cli@2.0.0. Thank you for the fix.

1 Like

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…

Does forcing the dependency on whatwg-fetch@2.0.4 solved your problem ?

1 Like

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! :slight_smile: thanks for the help

1 Like

thx it helped a lot!

UP: expo@30.0.1 added whatwg-fetch@2.0.4 as dependency. Problem is gone :wink:

1 Like

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.

Hello there,

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