0

I'm trying to use vue-chartjs but I'm having issues with the dependent chart.js installation.

Error:

ERROR in ./node_modules/vue-chartjs/dist/index.js 1:0-190 Module not found: Error: Package path ./dist/Chart.js/auto is not exported from package C:\Users...\project\node_modules\chart.js (see exports field in C:\Users...\project\node_modules\chart.js\package.json)

My package.json:

"dependencies": {
  "@vue-flow/core": "^1.41.6",
  "axios": "^1.7.9",
  "chart.js": "^4.4.7",
  "cors": "^2.8.5",
  "eslint-plugin-vue": "9.32.0",
  "pg": "^8.13.1",
  "pg-hstore": "^2.3.4",
  "register-service-worker": "^1.7.2",
  "sequelize": "^6.37.5",
  "vue": "^3.5.13",
  "vue-chart.js": "^0.2.0",
  "vue-chartjs": "^5.3.2",
  "vue-final-modal": "^4.5.5",
  "vue-good-table-next": "^0.2.2",
  "vue-i18n": "10.0.5",
  "vue-router": "4.5.0",
  "vue3-excel-editor": "^1.0.59"
}

Importing in my BarChart.vue component:

import { Bar, mixins } from "vue-chartjs";
import { Chart as ChartJS, Title, Tooltip, Legend, BarElement, CategoryScale, LinearScale } from 'chart.js'

All npm packages are up to date, also tried deleting the cache and using older versions of chart.js.

What could be the issue?

PS: Also does somebody know why there is vue-chartjs and vue-chart.js in my dependencies?

5
  • Most likely "vue-chart.js" is the source of your problems. It is an old package (latest release 2016) that comes with an included chart.js 2.9.4 distribution. It probably interferes with vue-chartjs and the latest chart.js distribution. npm uninstall it. Commented Jan 22 at 20:27
  • Hello kikon, I tried removing vue-chart.js, however I still get the same issues. Also, the vue-chartjs package was updated in Oktober 2024 so it should not be outdated. Is there some special way it needs to be imported? Commented Feb 6 at 15:38
  • vue-chartjs is certainly not outdated, there was no discussion about that, vue-chart.js is. Installing vue-chartjs is done by standard package installation, see the docs. If your npm uninstall of vue-chart.js didn't work, you may try starting a clean new project and installing only the packages that are needed then adding your code to it. It that fails too, you should try to reproduce the issue in a codesandbox or stackblitz and share it here on stackoverflow so we can help you. Commented Feb 6 at 16:10
  • Ok I see what you mean. "vue-chart.js" has been removed. I reinstalled both "vue-chartjs" and "chart.js" according to the documentation. There error is with the vue-chartjs package. It is the same as if I use chart.js myself: ERROR in ./node_modules/vue-chartjs/dist/index.js 1:0-185 Module not found: Error: Package path ./dist/Chart.js is not exported from package C:\**\node_modules\chart.js (see exports field in C:\**\node_modules\chart.js\package.json) chart.js: 4.47 vue-chartjs: 5.3.2 Commented Feb 7 at 9:06
  • I have switched to highcharts-vue, since I couldn`t find the issue. This plugins works perfectly fine. Thank you for trying to help in any case. Commented Feb 7 at 12:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.