Using ReactJS (^16.13.0) and npm.
Went through other issues, made sure to do npm install --save-dev worker-loader
after npm install [email protected]
but error didn't resolve. The only error that resolved was the this.WorkerClass is not a constructor
error mentioned in #85 .
Console logs this line multiple times:
worker.ts:16 Uncaught TypeError: CreateListFromArrayLike called on non-object at self.onmessage
Interestingly,
let v = new Vibrant(IMG);
console.log(v);
logs a Vibrant object with result(...), _src, and opts -- but errors persist.
I got the same error inside my angular 10 project.
I reverted to version 3.1.4 and with hat it works.
Same on my Vue project.
Vibrant: 3.2.1.alpha-1
Vue: 2.6.12
Was able to replicate this issue in React 17.0.1. Reverting to ^3.1.4
(thanks @a1development!) or ^3.1.6
fixes the problem for me.
My approach looks like this:
export const getColorPaletteFromBase64 = (base64String: string): Promise<Palette> => {
return new Promise((resolve, reject): void => {
const img = document.createElement('img');
img.src = base64String;
img.addEventListener(
'load',
async (): Promise<void> => {
const vibrant = new Vibrant(img);
const palette = await vibrant.getPalette();
resolve(palette);
},
);
});
};
^3.1.6
includes type definitions. Use this one instead!
Thanks, reverting to ^3.1.6 worked for me.
I was getting the same error within nuxt.js went from "node-vibrant": "^3.2.1-alpha.1", to "node-vibrant": "3.1.6",. This seemed to fix this issue. Thanks everyone above.
Most helpful comment
Thanks, reverting to ^3.1.6 worked for me.