-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
WebpackError: self is not defined #8612
Comments
@PierreBresson can you provide a reproduction repo for this? That would make it much simpler to diagnose this issue. |
I have the similar issue, was debugging all night and I found out it is coming from importing the firebase module. Just put this anywhere that code will be read... |
Got this error too after updating from Gatsby 2.0.0-beta.111 to 2.0.0-rc.28 |
Same issue here (happens when I try to import firebase) |
Same issue with whatwg-fetch, 2.0.4 → 3.0.0. |
Hi there, turns out you can use a null loader to allow it to build properly. Worked for me with firebase, at least: In gatsby-node:
|
Same issue |
@PierreBresson did you find a fix for this? |
Hey, guys. If you still facing this issue. I already created a Gatsby + Firebase starter that works. Tried with latest gatsby and latest firebase. https://github.com/muhajirframe/gatsby-starter-firebase |
I have this error with Gatsby 1 and Firebase 4, which are supposed to work together nicely |
Same with following set of dependencies:
|
Looks like Firebase is using a polyfill for Would it be safe to apply null-loader for firebase and wrap all it's calls into:
?? |
Removing firebase with a null-loader introduced lots of other issues in the project |
I'm having the same issue :/ error Building static HTML for pages failed See our docs page on debugging HTML builds for help https://goo.gl/yL9lND 1 | var support = {
WebpackError: ReferenceError: self is not defined
|
The implementation on starter above should fix the issue . Feel free to reopen again in case you still have an issue |
Can you not just tell us what you did to fix the issue? I'd rather not fork my project over to yours! that would take days. |
Sure, Basicly it load |
Awesome! Thank you! I have also found another solve for this issue,
|
@Douglashdaniel this used to work for me, but not it just started to run into the same error as above |
I feel like the solution proposed is misleading (at least without further explanation), for the following reasons:
|
@jpmasud after adding code you mentioned it throws another error - |
FWIW to future visitors of this thread, in response to my previous post, Firebase has an The reason Best of luck getting this working. I wrote about it in a blog post should you want more details of how I solved this problem: https://kyleshevlin.com/firebase-and-gatsby-together-at-last. |
I came to this thread due to Summary: I switched to |
importing it into the gatsby-browser.js file fixed it for me. |
what do you meant by "it" ? just tryed a few packages quoted here but didnt worked well. |
@adberard the issue was caused by 'window' not being defined in a gatsby build. I had imported 'whatwg-fetch' in a javascript file like normal but it needs adding to the gatsby-browser.js file here. import 'whatwg-fetch' I'm assuming firebase has the same issue where it's using fetch internally and using the library in a gatsby project is causing the same issue. |
Thanks @nevace, this helped. It is important to remove the 'whatwg-fetch' import in any other js file and solely import it in gatsby-browser.js |
This turned out to be a window undefined bug for me, I am using MongoDB Stitch which uses 'whatwg-fetch' as a dependancy. A simple truthy statement fixed it. const isWindow = typeof window !== 'undefined' && window componentDidMount() {
if (isWindow) {
const { Stitch } = require('mongodb-stitch-browser-sdk')
this.client = Stitch.initializeDefaultAppClient('xxxx')
}
} |
While the solution to import firebase in |
I tried and looks like this also works fine for providers. |
Sorted the issue for me. In my
The |
Tried the webpack solution which got past the performance Index issue, but now it fails on the Google Auth proviers. gatsby-node.js
|
In my case i was trying to connect to Stitch using mongodb-stitch-browser-sdk in a gatsby application and building of static html pages failed. |
@hsetially Can you show how did you use react-loadable and mongodb-stitch-browser-sdk ? Thanks |
Description
Suddently I cannot build anymore while develop is working well. I have the following error :
Steps to reproduce
Just run
gatsby build
Expected result
Get files in public folder.
Actual result
Crash on build. The real fun is that
gatsby build
used to work and I did tag a specific commit to make sure I can go back to this "working version". I revert to this commit and surprise, it's not working anymore.Environment
gatsby info --clipboard
package.json
The text was updated successfully, but these errors were encountered: