0

I'm making a Discord bot using discord.js so I don't use any HTML in my project. I wanted to use plotly.js but the npm package seems to be greatly outdated (last update late 2015) while the CDN link is kept updated. Is there a way to load it and use that instead? How could I get the same result that <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> would give me but in plain JS?

Tony
  • 123
  • 1
  • 1
  • 9
  • In my experience with CDN packages, getting the link directly from cdnjs.com and using that link as the src usually works for me. This is the link I found when searching for "plotly" at cdnjs.com: https://cdnjs.cloudflare.com/ajax/libs/plotly.js/1.51.1/plotly.min.js – developer01 Mar 20 '20 at 18:43
  • Read this https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js – Codebreaker007 Mar 20 '20 at 19:10
  • Does this answer your question? [Dynamically load JS inside JS](https://stackoverflow.com/questions/14521108/dynamically-load-js-inside-js) – Codebreaker007 Mar 20 '20 at 19:11

1 Answers1

0

I think you viewed the wrong package.

When checking out plotly.js/master/package.json, we can see that the name of the package is plotly.js, wich is found here: https://www.npmjs.com/package/plotly.js.

To install use npm i plotly.js.

Alternative you can insall directly from the master branch with npm i plotly/plotly.js.

PLASMA chicken
  • 2,462
  • 2
  • 13
  • 24
  • I just noticed this but gives me a ``var style = document.getElementById(id);`` error I'm assuming because I have no HTML in my project. Any workarounds? – Tony Mar 22 '20 at 20:22
  • It looks like plotly _was_ the correct package because it works on node https://github.com/plotly/plotly-nodejs#plotlygetimagefigure-options-callback so guess this cant be fixed :/ – Tony Mar 22 '20 at 20:37
  • What about `npm i plotly/plotly-nodejs` – PLASMA chicken Mar 23 '20 at 01:01
  • https://github.com/plotly/plotly-nodejs the repo hasn't really been updated for 4 years, that's what I'm using. – Tony Mar 23 '20 at 11:27