Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

ReferenceError: self is not defined after re-installing npm packages #28

Closed
apaatsio opened this issue Sep 10, 2018 · 5 comments
Closed
Labels

Comments

@apaatsio
Copy link

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:

  1. expo init foo (select tabs template)
  2. cd foo
  3. npm test (observe that tests work fine)
  4. rm -rf node_modules
  5. npm install
  6. npm 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
Copy link

iamnapo commented Sep 11, 2018

Try:

rm -rf node_modules
npm i whatwg-fetch@2.0.4 --save
npm install

@apaatsio
Copy link
Author

@iamnapo Thank you. That fixed the symptom. I wonder what the underlying problem is though. What does expo init do differently than npm install?

@iamnapo
Copy link

iamnapo commented Sep 11, 2018

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.

@corasan
Copy link

corasan commented Sep 13, 2018

I added GLOBAL.self = GLOBAL to the top of my App.js file so I guess doing npm i whatwg-fetch@2.0.4 --save is better

@ccheever
Copy link
Contributor

ccheever commented Oct 4, 2019

I tried this with the latest version of expo-cli and it doesn't appear to be a problem anymore.

image
(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!

@ccheever ccheever closed this as completed Oct 4, 2019
@lock lock bot added the outdated label Apr 2, 2020
@lock lock bot locked and limited conversation to collaborators Apr 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants