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.

ReferenceError: window is not defined

See original GitHub issue

window is undefined in code-runner. This is native code in browsers so it should be defined in code-runner.

I realise it doesn’t have a browser window to reference but it could maybe use the editor window as a reference point instead. If that’s not possible then using a generic fixed screen size for the sake of testing would be good enough to work with.

window should have all (or at least as many as possible) of the same values that can be found in a standard unmodified window object found in a modern browser.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eesaticommented, Jun 10, 2021

Use global instead

0reactions
formulahendrycommented, Sep 26, 2017

By default, Code Runner use Node.js to run JavaScript code, while Node.js not support window. You could choose other executor as you like.

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
First solution: typeof​​ Because typeof won't try to evaluate "window", it will only try to get its type, in our case in Node....
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 >
[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 >
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 >
ReferenceError : window is not defined at object. <anonymous ...
Well, that file seems to be running on the server, not the browser, and there is no window on the server? Node does...
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