react-plotly.js icon indicating copy to clipboard operation
react-plotly.js copied to clipboard

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

Open bluprince13 opened this issue 6 years ago • 5 comments

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 avatar May 18 '19 07:05 bluprince13

I just had to install plotly.

npm install plotly.js

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

bluprince13 avatar May 18 '19 08:05 bluprince13

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.

MatthewMarichiba avatar Nov 06 '19 21:11 MatthewMarichiba

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.

Stephan-Brandt avatar Feb 28 '20 14:02 Stephan-Brandt

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

oeph avatar Mar 02 '20 18:03 oeph

@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:

Stephan-Brandt avatar Mar 03 '20 10:03 Stephan-Brandt