document is not defined
See original GitHub issueDescribe the bug
While all is working as expected 3.4.2
, if I update to 3.5.6
I can’t render monaco editor properly
09:56:48.557 | > Build error occurred
-- | --
09:56:48.558 | ReferenceError: document is not defined
09:56:48.558 | at Object.<anonymous> (/vercel/19c883f1/node_modules/@monaco-editor/react/lib/utils/monaco.js:86:43)
09:56:48.558 | at Module._compile (internal/modules/cjs/loader.js:1156:30)
09:56:48.558 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
09:56:48.558 | at Module.load (internal/modules/cjs/loader.js:1000:32)
09:56:48.558 | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
09:56:48.558 | at Module.require (internal/modules/cjs/loader.js:1042:19)
09:56:48.558 | at require (internal/modules/cjs/helpers.js:77:18)
09:56:48.558 | at Object.<anonymous> (/vercel/19c883f1/node_modules/@monaco-editor/react/lib/utils/index.js:47:38)
09:56:48.558 | at Module._compile (internal/modules/cjs/loader.js:1156:30)
09:56:48.558 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
09:56:48.558 | at Module.load (internal/modules/cjs/loader.js:1000:32)
09:56:48.558 | at Function.Module._load (internal/modules/cjs/loader.js:899:14)
09:56:48.558 | at Module.require (internal/modules/cjs/loader.js:1042:19)
09:56:48.558 | at require (internal/modules/cjs/helpers.js:77:18)
09:56:48.558 | at Object.<anonymous> (/vercel/19c883f1/node_modules/@monaco-editor/react/lib/Editor/Editor.js:22:14)
09:56:48.558 | at Module._compile (internal/modules/cjs/loader.js:1156:30)
This is how monaco is loaded from the code: https://github.com/microlinkhq/cards/blob/38f3bac85536de9caac9bb8d61f97d136bb45a60/packages/app/src/components/live-editor.js#L74
To Reproduce
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
ReferenceError: document is not defined (in plain JavaScript)
Explanation: The error is caused because NextJs renders the page in the server only and in the server document (document is used inside...
Read more >ReferenceError: document is not defined in JavaScript
The "ReferenceError: document is not defined" error occurs for multiple reasons: ... The document relates to the document object which represents a web...
Read more >ReferenceError: document is not defined in JavaScript
The "ReferenceError: document is not defined" error is thrown when the code tries to access the document object, but the object is not ......
Read more >How to fix ReferenceError: Document is not defined ... - Sabe.io
The most common reason for getting the reference error while on the browser is when you try to access the document object too...
Read more >How to solve the document is not defined error - Flavio Copes
Here's how to fix the “referenceerror: document is not defined” error that you might have in Node.js or with a tool like 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
hey 3.5.7 is working fine! 🙂
Hi @Kikobeats,
The problem was
Next.js
, it doesn’t “accept”document
in server-side rendering. There are many issues out there about that. I’ve just modified my functions a little bit to avoid interacting withdocument
during lazy parsing.Please, check the new version - v3.5.7 Let me know if it works.