in gatsby window is not defined issue!
See original GitHub issueit seems an old issue but in the gatsby branch seems to remains error log: `error Building static HTML failed
See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html
22 | var cachedScrollbarWidth = null; 23 | var cachedDevicePixelRatio = null;
24 | window.addEventListener(‘resize’, function () { | ^ 25 | if (cachedDevicePixelRatio !== window.devicePixelRatio) { 26 | cachedDevicePixelRatio = window.devicePixelRatio; 27 | cachedScrollbarWidth = null;
WebpackError: ReferenceError: window is not defined`
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Gatsby - the window is not defined error, what and how to fix it?
You can check if the browser-global object window is defined and based on it, execute the related code block. ... The variable isBrowser...
Read more >Window is not defined · Issue #309 · gatsbyjs/gatsby - GitHub
I'm trying to use a semantic-ui import along with my components. Works fine in development but if I try to gatsby build ,...
Read more >Debugging HTML Builds | Gatsby
If this is your problem you should see an error above like “window is not defined”. To fix this, find the offending code...
Read more >Gatsby - Window Is Not Defined? - Tanner Langlinais
When gatsby build runs, it renders all React components server-side. The problem is that there is no window object server-side.
Read more >ReferenceError: Window Is Not Defined in GatsbyJS
Debugging why your GatsbyJS (or NextJS) build is failing when you receive the message 'window is not defined'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I just added simplebar-react v2.3.0 to my gatsby project (gatsby v2.24.80) and can build perfectly well. I think this issue can be closed.
Hi @shavidzet ,I was having the same issue and after reading other git issues and testing different versions I found the one that works for me:
Initially I tried the one suggested here: https://github.com/Grsmto/simplebar/issues/396 but didn’t work for me then after seeing this post, I looked up for the latest release and I found this one.
simplebar-react@2.0.6-corejs2
I was able to run gatsby build with no issues.
Thanks @Grsmto for all the hardwork!