Chartjs-"Process is not defined" with react-chartjs-2 CDN

1👍

The library, like most React components, does not support the browser natively. It assumes it’s in a build tool environment (i.e. Node.js) so it thinks there’s already a global process object. This is an oversight by the developers, but your use case is relatively uncommon, so they don’t test it.

You need to use a build tool like Webpack, Rollup, or Parcel to be able to use that library.

PS: to reduce bundle size you should use .min.js CDNs instead of .js, i.e. have the URL be https://cdnjs.cloudflare.com/ajax/libs/react-chartjs-2/2.9.0/react-chartjs-2.min.js.

Leave a comment