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

134
Vistas
importing ColorThief doesn't work and messes up code

I tried to import ColorThief into my code but I get an error saying

Uncaught SyntaxError: Cannot use import statement outside a module

I don't know what to do since I just copied the import statement on the ColorThief website, and I downloaded the node-module thing so the path is correct.

In addition I found out that the import statement causes another error. It causes my setBio function to be "declared but never read" but I used it in my HTML file like this:

<button onClick=setBio()>Search</button>

The error disappears and everything works (all the features I implemented before trying to implement a color thief feature) once I comment out the import statement.

Here's a condensed version of what's in my JS file:

import ColorThief from './node_modules/colorthief/dist/color-thief.mjs'

let setBio = async () =>
{
    let input = document.getElementById("input");
    let pokemon = input.value.toLowerCase();
    input.value = ""

    let display = document.getElementById("name");
    display.innerHTML = await getName(pokemon);

    let pic = document.getElementById("img");
    pic.src = await getPic(pokemon);
    setBGColor();
}

Any help would be appreciated. I am new so I apologize if it's something stupid

about 4 years ago · Juan Pablo Isaza
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