Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

217
Views
vue-chartjs can't import data from vue

I get this error after compiling my Vue 2 project:

Failed to compile.

./node_modules/vue-chartjs/dist/index.js 85:11-26
"export 'defineComponent' was not found in 'vue'

The line in the file above that is causing this behavior is:

import { defineComponent, shallowRef, ref, watch, onMounted, onBeforeUnmount, toRaw, h, isProxy } from 'vue';

All of these imports cause the same error. This happens after I upgrade vue-chartjs from version 3.5.1 to version 4.1.1 (before it works perfectly). I'm looking for ideas on what might be causing this.

The versions of used dependencies are:

- "chart.js": "^3.8.0"
- "vue": "^2.6.14"
- "vue-chartjs": "^4.1.1"

Unfortunately, I cannot provide a snippet. This happens only on a project which is in use at work. If I try this on a clean project, it compiles perfectly. The Internet is almost void in regard to information on Vue, so I'm just looking for any idea.

Anything you can think of that could cause this, please share. Even the dumbest idea may help, I've been scouring the Internet for days and I can't find anything. This is getting super frustrating, all I wanted to do was upgrade chart.js and it's taking me days, lol.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I guess you are trying to import the lib like so:

import { Bar } from 'vue-chartjs'

This won't work for you since you are using Vue2. To use the Vue wrapper with Vue2 you will need to import from 'vue-chartjs/legacy'. In here they have support for Vue V2 and then your application should compile just fine.

Correct import for you:

import { Bar } from 'vue-chartjs/legacy'

Comming from their readme

about 4 years ago · Juan Pablo Isaza Report

0

This error is usually coming from the fact that you're using a Vue3 specific version. As explained here: "export 'default' (imported as 'Vue') was not found in 'vue'

Checking the releases page of vue-chartjs, we can see that v4.0.0 had a breaking change of migrating to Vue3: https://github.com/apertureless/vue-chartjs/releases/tag/v4.0.0

Hence why the v4 is causing such problem. Stay at v3.5.1 (22 august 2020) or below if you're stuck with a Vue2 usage.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!