"ReferenceError: window is not defined"
See original GitHub issueI got a weird issue when using nuxt-mq with nuxt v2.14.6. When I run npm run dev
and refresh the browser the initial request renders and displays the site as expected. However when I refresh the page I get this error:
"ReferenceError
window is not defined"
function subscribeToMediaQuery(mediaQuery, enter) {
var mql = window.matchMedia(mediaQuery);
var cb = function cb(_ref) {
I’ve included the nuxt-mq module in the modules prop of the nuxt config and supplied a config for it but this error seems to stay even though I alter the config.
TLDR:
Page renders on first load after npm run dev
but when refreshing the page we get an error: ‘window is not defined’ from nuxt SSR.
Have anyone seen this before and might help me out on what I’m doing wrong? 😃
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to solve "window is not defined" errors in React and ...
How to solve "window is not defined" errors in React and Next.js · 1. First solution: typeof · 2. Second solution: the useEffect...
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 don't...
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 >How To Solve ReferenceError window is not defined in ...
Fixing a window is not defined error can be quite simple. In most cases, all you will need to do is wrap your...
Read more >[Solved] ReferenceError : window is not defined - ItsJavaScript
The ReferenceError : window is not defined error mainly occurs if you are using the window object in Node.js, React.js, Next.js.
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 FreeTop 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
Top GitHub Comments
👍 Just ran into this bug in my Nuxt project that uses chakra-ui-vue
Ah nice, I switched too – I ended up using nuxt-viewport.