How to run charts.js fully locally?

Hi,
hope you guys are doing well.
I wonder if somebody of you could give me some hints, how to run charts.js locally (no loading of cdn, npm etc. via internet → just all things on a local pc with no internet connection).
Thank you for help!
Best

Say that you create a project with this structure:

myFolder
  package.json
  index.html
  index.js
  node_modules

If you install any program via NPM (without the --global flag), it will remain as a javascript file under node_modules/charts.js (or a similar name). [[By the way, when you publish an npm package and someone installs it, it just searches for your scripts and puts them in the user node_modules folder.]]

So:

  1. Switch to your project folder
  2. Install via npm (npm install chart.js --save)

And then you have it forever there. Check installation instructions here.

Next include something like <script src="./node_modules/chart.js/dist/Chart.js"></script>

Then it will be available other scripts loaded right below (otherwise the stuff is undefined.)

Thank you!! Now everything works fine.

1 Like