Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

220
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda