Vibrant-Colors / node-vibrant

🎨 Extract prominent colors from an image
MIT License
2.01k stars 107 forks source link

ES6 import is wrong? #127

Open PierBover opened 3 years ago

PierBover commented 3 years ago

In Node, this doesn't work:

import * as Vibrant from 'node-vibrant'

I get the error:

TypeError: Vibrant.from is not a function

Instead I'm using the regular import which works as expected:

import Vibrant from 'node-vibrant'

Do you want me to make a PR to fix the docs?

bitdom8 commented 2 years ago

Hi @PierBover , how have you managed to get it working w/ ES6?

PierBover commented 2 years ago

@bitdom8 import it like this:

import Vibrant from 'node-vibrant';

And then use it like this:

const colors = await Vibrant.from(filePath).getPalette();
bitdom8 commented 2 years ago

Thanks @PierBover . It works great with :)))

pnpm run dev

however, when following is done, no use:(;

pnpm run build 
pnpm run preview

here is my dependencies: "devDependencies": { "@sveltejs/kit": "next", "@types/cookie": "^0.4.0", "@typescript-eslint/eslint-plugin": "^4.19.0", "@typescript-eslint/parser": "^4.19.0", "eslint": "^7.22.0", "eslint-config-prettier": "^8.1.0", "eslint-plugin-svelte3": "^3.2.0", "install": "^0.13.0", "prettier": "~2.2.1", "prettier-plugin-svelte": "^2.2.0", "sass": "^1.41.0", "svelte": "^3.34.0", "svelte-check": "^2.0.0", "svelte-preprocess": "^4.0.0", "tslib": "^2.0.0", "typescript": "^4.0.0" }, "type": "module", "dependencies": { "@fontsource/fira-mono": "^4.2.2", "@lukeed/uuid": "^2.0.0", "cookie": "^0.4.1", "filepond": "^4.29.0", "filepond-plugin-image-exif-orientation": "^1.0.11", "filepond-plugin-image-preview": "^4.6.8", "fuse.js": "^6.4.6", "nanoid": "^3.1.25", "node-vibrant": "3.1.6", "simple-svelte-autocomplete": "^2.2.3", "svelte-emoji-selector": "^1.0.1", "svelte-i18n": "^3.3.10" }

Even change Githubissues.

  • Githubissues is a development platform for aggregating issues.