Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: self is not defined #192

Closed
ythecombinator opened this issue Sep 10, 2017 · 4 comments · Fixed by #193
Closed

ReferenceError: self is not defined #192

ythecombinator opened this issue Sep 10, 2017 · 4 comments · Fixed by #193

Comments

@ythecombinator
Copy link

ythecombinator commented Sep 10, 2017

Hey, thanks for the amazing component!

I've been making a few experiments with it and I ended up facing the following:

self is not defined
ReferenceError: self is not defined
    at Object.<anonymous> (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:19:58659)
    at t (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:1:177)
    at Object.module.exports.Object.defineProperty.value (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:19:173470)
    at t (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:1:177)
    at Object.module.exports.Object.defineProperty.value (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:19:166713)
    at t (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:1:177)
    at Object.module.exports.Object.defineProperty.value (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:19:101177)
    at t (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:1:177)
    at Object.<anonymous> (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:49:115114)
    at t (/Users/mabrasil/Documents/Github/beakyn/docs/final2/node_modules/react-lincoln/Lincoln.js:1:177)

There're many other related issues out there and it seems to be a problem with webpack–and not with Lincoln itself–but none of the solutions seemed to be related.

One of the comments got my attention:

The problem here is that global.self is only defined in Browsers and Web Workers. Unit tests running in NodeJs environment won't have access to global.self.

I think this can be kind of a clue, since I'm doing server-side rendering with next.js but I still can't figure it out.

Any thoughts?

@nfour
Copy link
Collaborator

nfour commented Sep 12, 2017

While it would be not-ideal, assembling a jsdom environment inside your server-side rendering could fix it.

The line in question:
self.fetch.bind

So it's trying to reference fetch from a global and failing in nodejs. Definitely sounds like a webpack problem or perhaps babel.

@brendo
Copy link
Contributor

brendo commented Sep 12, 2017

Looks like this could be semi-related too, matthew-andrews/isomorphic-fetch#125

@brendo
Copy link
Contributor

brendo commented Sep 12, 2017

Yo @ythecombinator, I think we might have a fix, did you want to try the above PR?

@ythecombinator
Copy link
Author

Gonna check this later @nfour and @brendo. Thanks for the fast feedback 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants