Hi, I’m trying to use chart.js and moment.js using requireJS, but I always get the following error:
Error: Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com
I can use
Chart.bundle.js and it works but I can’t use
moment from it, so I need to import it independently.
I’ve tried to find any example on the web without success. And the docs says that:
The Chart.bundle.js and Chart.bundle.min.js builds include Moment.js in a single file. This version should be used if you require time axes and want a single file to include, select this version. Do not use this build if your application already includes Moment.js. If you do, Moment.js will be included twice, increasing the page load time and potentially introducing version issues.
But the examples in the repository import it twice…
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script> <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="../../dist/Chart.bundle.js"></script>