Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node package causes errors #437

Closed
bryaan opened this issue Apr 17, 2016 · 3 comments
Closed

Node package causes errors #437

bryaan opened this issue Apr 17, 2016 · 3 comments

Comments

@bryaan
Copy link

bryaan commented Apr 17, 2016

Calling plotly like this:

var Plotly = require('plotly.js');

Causes this:

/Users/bryan/tibra/web3/node_modules/plotly.js/src/lib/index.js:416
        var style = document.createElement('style');
                    ^
ReferenceError: document is not defined
    at Object.lib.addStyleRule (/Users/bryan/tibra/web3/node_modules/plotly.js/src/lib/index.js:416:21)
    at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/build/plotcss.js:61:16)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/src/plotly.js:30:1)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/Users/bryan/tibra/web3/node_modules/plotly.js/src/core.js:15:14)

@etpinard
Copy link
Contributor

plotly.js is browser package, with no intention of working in vanilla node.js.

In order to do so, you'll need use jsdom (or a similar package).

Here's my preliminary attempt: https://gist.github.com/etpinard/bee7d62b43b6bb286950

I ran into a few issues, and it is not in a working state. But, we hope to solve these issue shortly to offer server-side plotly.js rendering.

@tgoldenberg
Copy link

What about web frameworks that use SSR (server-side rendering)?

We use Next.js, which server-renders first, and it is a bug for us as well.

@etpinard
Copy link
Contributor

and it is a bug for us as well.

Even when using jsdom?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants