ReferenceError: window is not defined -- Globe.gl/Three

Hi,

I’m able to ‘successfully’ build a globe.gl app, but when trying to see it running, I get a “window is not defined” error. I have tried a lot of options, but no success. Any advice?

==> Running ‘node dist/globe.gl.mjs’

file:///opt/render/project/src/node_modules/three-conic-polygon-geometry/dist/three-conic-polygon-geometry.mjs:389

var THREE = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists

ReferenceError: window is not defined

Hi,

It looks like you’re trying run a javascript file that reference window on the server-side. window is available to JavaScript in the browser, not on the server-side (in Node).

Render Web Services expect an HTTP server to be started in the Start Command (Express, being commonly used in Node). Maybe you need to serve some HTML with your JavaScript files included to display your globe?

Alan

Thanks, Alan! Apologies for the delay in answering, as I was away on vacation.

I confess this is my first try with Node and Globe.gl, so I appreciate your clear answer and patience. So far, everything seems to run perfectly on my local computer, but not on Render. I included this html file (just renamed it “index.html” in case that was the issue) but still nothing.

Perhaps there’s something I need to add to the file? Again, just like that it runs without issues on my local computer, but perhaps Render needs something extra?

Thanks for your advice

If you want to serve a file with a Web Service you need to use a web server to serve those files. I mentioned that in my last message:

Render Web Services expect an HTTP server to be started in the Start Command (Express, being commonly used in Node).

If you just want to serve just static files, you may be able to use a Static Site

Alan

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.