Closed talentlessguy closed 1 year ago
node-canvas
is not actually a dependency of color-thief. The actual dependency that's causing this is lokesh/quantize which is referenced in the package.json like this:
"dependencies": {
"get-pixels": "^3.3.2",
"quantize": "github:lokesh/quantize"
}
Since npm 7.0.9, when referencing dependencies like this (github:
), npm will try to install the devDependencies
of the dependencies of lokesh/quantize. This issue is tracked here: https://github.com/npm/cli/issues/2784.
Because lokesh/quantize has a devDependency on microbundle@0.11.0, and this version of microbundle uses node-gyp, and these packages require additional development tools to be installed, we run into issues when trying to install color-thief.
There are numerous solutions/workarounds:
github:
-style dependency in color-thiefUntil npm or lokesh makes a move, your only option is number 4.
Until npm or lokesh makes a move, your only option is number 4.
or
npm@6.14.4
+ node@12.18.0
worked fine for me with color-thief@2.2.5
.Ah of course, that's also an option. npm 7.0.8 or lower should work fine.
The recent versions of npm support overrides
to replace a version of dependency.
Using the quantize
fork of @RudeySH works for me. Tested node@18.0.0
+ npm@8.9.0
.
{
"dependencies": {
"colorthief": "^2.3.2"
},
"overrides": {
"quantize": "github:RudeySH/quantize"
}
}
UPDATE: I created a monorepo with colorthief
including some (abandoned) dependencies that needed an update too. It's not super classy to share it here but we are losing so much time collectively trying to fix this. Please head over to https://github.com/pioug/colorsuite. If anyone is interested in keeping the project/repository alive, ping me there, I'll add you as a maintainer.
npm install colorthief@npm:@pioug/colorthief
thanks @pioug works great! 👍
Have @lokesh turn lokesh/quantize into an actual npm package, and replace the github:-style dependency in color-thief
Finally... done. The package on npmjs.com: https://www.npmjs.com/package/@lokesh.dhakar/quantize
The latest release of color-thief updates the quantize dep reference in package.json: https://github.com/lokesh/color-thief/releases/tag/v2.4.0
system info
node: v15.11.0 pnpm: 5.18.3 npm: 7.6.0
When trying to install
color-thief
with pnpm, I get this: