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

133
Views
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
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!