chartjs / chartjs-plugin-annotation

Annotation plugin for Chart.js
MIT License
606 stars 328 forks source link

vitest ERR_PACKAGE_PATH_NOT_EXPORTED #819

Closed hugo-valcourt closed 1 year ago

hugo-valcourt commented 1 year ago

Hi,

I'am investigating on a problem when testing component using Chart.js chartjs-plugin-annotation on vitest.

I got the error ERR_PACKAGE_PATH_NOT_EXPORTED. Maybe related to chartjs-plugin-zoom bug https://github.com/chartjs/chartjs-plugin-zoom/issues/709

When I remove "chartjs-plugin-annotation" and "chartjs-plugin-zoom" everything is working.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Error: No "exports" main defined in /.../node_modules/chart.js/package.json
    "chart.js": "^4.0.1",
    "chartjs-adapter-luxon": "^1.3.0",
    "chartjs-plugin-annotation": "^2.1.0",
    "chartjs-plugin-zoom": "^2.0.0",
    "@vue/test-utils": "^2.2.6",
    "jsdom": "^20.0.3",
    "vitest": "^0.25.6",
    "vitest-canvas-mock": "^0.2.2",
 ❯ node_modules/chartjs-plugin-annotation/dist/chartjs-plugin-annotation.js:8:89
      6|  */
      7| (function (global, factory) {
      8| typeof exports === 'object' && typeof module !== 'undefi…
       |                                                                                         ^
      9| typeof define === 'function' && define.amd ? define(['ch…
     10| (global = typeof globalThis !== 'undefined' ? globalThis…

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Serialized Error: {
  "code": "ERR_PACKAGE_PATH_NOT_EXPORTED",
}
stockiNail commented 1 year ago

See issue #814 A PR is already submitted. It needs to be of last update

stockiNail commented 1 year ago

@hugo-valcourt could you try with new CHART.JS version 4.1.1? With that version and plugin 2.1.0, it should work.

hugo-valcourt commented 1 year ago

working after upgrade! thanks!