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: document is not defined

See original GitHub issue

This dependency makes it impossible to use plotly.js in the browser because image-size uses fs module which is not available in browsers. I do not know how does react-plotly.js adapt to this dependency but I guess they have this issue too.

Related to: https://github.com/plotly/plotly.js/pull/5119.

Reproducible example

  1. Create an app with create-react-app.
  2. Install dependencies from the screenshot below (you might need to change the React and ReactDOM packages’ versions too), including plotly.js@1.57.1 and use it as a dynamic import with @loadable/component.
  3. Run yarn start in the project directory.

Screenshot

image

Expected output

The app runs well without terminal or browser errors.

Actual output

Error inside browser window:

image

Update

The essence of this issue is here: https://github.com/plotly/plotly.js/issues/5243#issuecomment-724028727

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
archmojcommented, Jan 15, 2021

@archmoj The error related to the module image-size is gone (with the latest commit in plotly.js#master) in the project I work on, although I did not test inside CodeSandbox. Is it possible to tell when will the change be included in a GitHub release? Thank you!

Thanks for testing this out. We are working on a major release now that involves days of QA. So v2 might be out around Jan 25, I hope.

1reaction
archmojcommented, Jan 8, 2021

@silviubogan would you mind testing if the issue was resolved after #5388?

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
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 >
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 >
How To Fix ReferenceError document is not defined ... - Isotropic
If you are trying to use the document object and receiving a ReferenceError: document is not defined error then there is a good...
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 >

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