Discussion of "Uncaught [ReferenceError: document is not defined]" error when deploying GraphQL in Sanity
16 replies
Last updated: Feb 5, 2021
Anyone ever run into this one? when deploying the graphql? It errors midway but still successfully deploys 🤔 (Just ran a sanity upgrade just in case, but still persists!)
Uncaught [ReferenceError: document is not defined]
Anyone ever run into this one? `Uncaught [ReferenceError: document is not defined]` yarn deploy:graphql yarn run v1.22.10 $ sanity graphql deploy --playground Dataset: production Tag: default ✔ Checking for deployed API ✔ Generating GraphQL schema ⠋ Validating GraphQL APIError: Uncaught [ReferenceError: document is not defined] –––––[FULL ERROR IN THREAD]––––– ✔ Validating GraphQL API ✔ Deploying GraphQL API GraphQL API deployed to: [myGraphQlPlaygroundUrlHere]
Jan 31, 2021, 4:14 PM
Uncaught [ReferenceError: document is not defined] at reportException (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:66:24) at innerInvokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:312:9) at invokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:251:3) at DocumentImpl._dispatch (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:205:11) at DocumentImpl.dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17) at dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:488:13) at /Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:493:11 at new Promise (<anonymous>) at onDOMContentLoad (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:491:14) at Object.check (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/browser/resources/resource-queue.js:76:23) ReferenceError: document is not defined at Object.highlightAll (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/prismjs/components/prism-core.js:530:23) at Document.highlightAutomaticallyCallback (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/prismjs/components/prism-core.js:1193:5) at innerInvokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:296:27) at invokeEventListeners (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:251:3) at DocumentImpl._dispatch (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:205:11) at DocumentImpl.dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17) at dispatchEvent (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:488:13) at /Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:493:11 at new Promise (<anonymous>) at onDOMContentLoad (/Users/r.derolez/code/helloastro/helloastro-cms/node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:491:14)
Jan 31, 2021, 4:15 PM
C
I've been getting this constantly ever since upgrading sanity this week. After incrementally adding bits to a brand new empty studio I found mine throwing this error when I included a few specific plugins.
The plugins themselves were still working and the gql redeployed correctly.
I upgraded an old build and started getting the same error. Very odd
The plugins themselves were still working and the gql redeployed correctly.
I upgraded an old build and started getting the same error. Very odd
Jan 31, 2021, 6:37 PM
Do you have any syntax highlighting plugin or code preview/input installed in your studio? It seems to be stemming from prism (a syntax highlighter) using
documentin a node.js context.
Jan 31, 2021, 9:48 PM
C
user Z
from a completely blank studio mine was producing this error when adding the "color-list" plug in. Removing the plugin stopped the errorFeb 1, 2021, 12:16 PM
user G
Are you also using the "color-list" plugin, or a different one? There's several color plugins out thereFeb 1, 2021, 11:10 PM
K
I’ve got the same problem, and the same plugin.
Feb 2, 2021, 4:15 AM
Found the culprit - https://github.com/sanity-io/sanity/pull/2279 Hoping to have a fix in a day or two
🙂
🙂
Feb 2, 2021, 5:49 AM
K
🤘
Feb 4, 2021, 5:53 PM
C
Cheers!! 😁
Feb 5, 2021, 12:46 PM
Sanity– build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.