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.

window is not defined

See original GitHub issue

An error happens during build after recent update to @brainhubeu/react-carousel@1.12.6: ReferenceError: window is not defined at Object.<anonymous> ([ROOT]/react/node_modules/ brainhubeu/react-carousel/lib/react-carousel.js:1:279

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

12reactions
Sorvereigncommented, Feb 26, 2020

Hi, I was having the same issue with NextJS, I tried to check the source code but I didn’t find anything weird so I find a solution for this. What I did was dynamic importing with no SSR

So, instead of the traditional importing: import Carousel from '@brainhubeu/react-carousel'

Do:

//This first import dynamic from ‘next/dynamic’;

const Carousel = dynamic( () => import (‘@brainhubeu/react-carousel’), { ssr: false } )

This works for me, have a nice day.

7reactions
piotr-s-brainhubcommented, Feb 26, 2020

@nescha @Neddz @Sorvereign

I have a workaround https://github.com/brainhubeu/react-carousel/pull/292 I published it as @brainhubeu/react-carousel@1.12.9-alpha. Could you check whether it works for you? Do you think my workaround is better or using next?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve "window is not defined" errors in React and Next.js
How to solve "window is not defined" errors in React and Next.js · 1. First solution: typeof · 2. Second solution: the useEffect...
Read more >
ReferenceError: window is not defined in JavaScript
The "ReferenceError: window is not defined" error occurs for multiple reasons: ... The window object represents a window containing a DOM document and...
Read more >
How to solve Next.js window is not defined
ReferenceError : window is not defined is a pretty common error you may run into when using Next.js for the first time but...
Read more >
Javascript: 'window' is not defined - Stack Overflow
The window object represents an open window in a browser. Since you are not running your code within a browser, but via Windows...
Read more >
referenceerror: window is not defined, how to solve
Here's how to fix the “referenceerror: window is not defined” error that you might have in Node.js or with a tool like Next.js....
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