chartjs-plugin-datalabels icon indicating copy to clipboard operation
chartjs-plugin-datalabels copied to clipboard

chartjs-plugin-datalabels with requirejs (ReferenceError: module is not defined)

Open andrepintado opened this issue 3 years ago • 1 comments

Hello guys,

I'm currently trying to set up chartjs 3 + chartjs datalabels 2 along with requirejs, and I'm getting the following errors:

helpers.js:1 Uncaught ReferenceError: module is not defined

chartjs-plugin-datalabels.min.js:7 Uncaught TypeError: Cannot read properties of undefined (reading 'merge')

Here's my requirejs config:

requirejs.config({
  paths: {
    'chartjs': '../vendor/chart.js/dist/chart.min',
    'chartjs-plugin-datalabels': '../vendor/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.min',
  },

  shim: {
    'chartjs-plugin-datalabels': {
      deps: ['chartjs']
    },
  },

  map: {
    'chartjs-plugin-datalabels': {
      "chart.js": "chartjs",
      "chart.js/helpers": "../vendor/chart.js/helpers/helpers"
    }
  }
});

Everything was working well with chartjs 2 + chartjs datalabels 1, but with this upgrade, it's not anymore. I'm guessing it has to do with the module.exports = require('..').helpers; in helpers.js, but I don't know how to fix this.

Can you help me? Thanks a lot

andrepintado avatar Apr 20 '22 18:04 andrepintado

@andrepintado It looks like something specific to require.js so it may be better to ask this question in their repository. If you think there is a bug in this library, please provide a way for us to reproduce and debug your issue.

simonbrunel avatar Aug 03 '22 07:08 simonbrunel