plotly / react-plotly.js

A plotly.js React component from Plotly 📈
MIT License
1.02k stars 136 forks source link

Can't resolve 'plotly.js/dist/plotly' #143

Open bluprince13 opened 5 years ago

bluprince13 commented 5 years ago

I get the following error when I start my react app.

./node_modules/react-plotly.js/react-plotly.js
Module not found: Can't resolve 'plotly.js/dist/plotly'
bluprince13 commented 5 years ago

I just had to install plotly.

npm install plotly.js

Shouldn't it be installed automatically if it is a dependancy?

MatthewMarichiba commented 4 years ago

I saw this same behavior. If you have plotly declared as a dependency in package.json, it is worth noting that "plotly" and "plotly.js" are different things. You want "plotly.js". I got hasty letting my IDE auto-complete package names for me, and got the wrong one.

Stephan-Brandt commented 4 years ago

I have the same problem and have found that I can only get it to work with "plotly.js" and not the (in my understanding) recommended plotly.js-dist. Are there real compatibility issues or is the update outstanding. This is an issue for me since for plotly.js npm throws 8 audit warnings.

oeph commented 4 years ago

I'm currently using this with plotly.js-dist. You can just use the factory.js with your own plotly dist.

import plotComponentFactory from "react-plotly.js/factory";
import Plotly from "plotly.js-dist";

const PlotComponent = plotComponentFactory(Plotly);

export default PlotComponent;

CodeSandbox link: https://codesandbox.io/s/fancy-smoke-9jlm3?fontsize=14&hidenavigation=1&theme=dark

Stephan-Brandt commented 4 years ago

@oeph Works like a charm, thank you. It might be beneficial to mention/link this option in the installation section of the README. I admit, I should have seen it, but imo it does not hurt making it idiot proof :smiley: