Closed notbrian closed 5 years ago
@notbrian gatsby is a server side framework. that means that when you issue gatsby build
or gatsby develop
all of your pages/components and other assorted assets are bundled and processed by node. So with that in mind certain apis like window
, document
are not available in node. With that some measures are needed to bypass these errors. If you don't mind i'm currently working on the fininishing touches for your other issue #17197 based on your latest input there and this new information. If you don't mind i'll post a detailed answer shortly.
Much appreciated, thanks @jonniebigodes!
Seems like this is a duplicate issue of https://github.com/gatsbyjs/gatsby/issues/17197 Please continue there! Thanks
Summary
I use a three.js canvas in my project and gatsby develop runs fine but when I try to build my project I get a
ReferenceError: document is not defined
error.Relevant information
I'm using
react-three-fiber
which is a wrapper around the basethree
library. I previously tested building a month or so ago and everything worked fine. I recently updated all the modules in my project which is when I started encountering this error. I'm not 100% sure if this is caused by Gatsby.My stack trace:
Then the actual line of code in render-page that is causing the error:
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
: N/Agatsby-browser.js
: N/Agatsby-ssr.js
: N/A