`ReferenceError: self is not defined` after re-installing npm packages
I have a fresh project using the tabs template and I'm getting ReferenceError: self is not defined after I re-install npm packages.
To reproduce:
expo init foo(select tabs template)cd foonpm test(observe that tests work fine)rm -rf node_modulesnpm installnpm test
Actual result:
FAIL __tests__/App-test.js
● Test suite failed to run
ReferenceError: self is not defined
at node_modules/whatwg-fetch/dist/fetch.umd.js:8:40
at Object.<anonymous>.support.searchParams (node_modules/whatwg-fetch/dist/fetch.umd.js:2:66)
at Object.<anonymous> (node_modules/whatwg-fetch/dist/fetch.umd.js:5:2)
at Object.<anonymous> (node_modules/jest-expo/src/setup.js:7:47)
Expected result:
Tests pass.
Versions
- expo 29.0.0
- expo-cli 1.1.0
- node 9.11.2
- npm 5.6.0
- yarn 1.9.4
- OS: Linux Manjaro
@iamnapo Thank you. That fixed the symptom. I wonder what the underlying problem is though. What does expo init do differently than npm install?
I think this is the problem (isomorphic-fetch is a module expo uses). npm install installs the newly released v3 of whatwg-fetch, which seems to cause the problem, whereas expo init uses its own lockfile and installs a previous version.
I added GLOBAL.self = GLOBAL to the top of my App.js file so I guess doing npm i [email protected] --save is better
I tried this with the latest version of expo-cli and it doesn't appear to be a problem anymore.
(after doing the rm -rf node_modules and npm install)
I'll close for now. But please reopen (and give more details) if you encounter this again!