question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

in gatsby window is not defined issue!

See original GitHub issue

it 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:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
barbalexcommented, Oct 18, 2020

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.

1reaction
dnpgcommented, Jun 21, 2020

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!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found