itgalaxy / favicons

Favicons generator for Node.js
MIT License
1.19k stars 164 forks source link

release 7.1.5 with sharp 0.33.1 will not build #448

Closed zburke closed 11 months ago

zburke commented 11 months ago

After bumping from v7.1.4 to v7.1.5 all builds now fail with the following error:

/var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/index.js:656
    throw new Error(
          ^

Error: Could not find the npm peerDependency "favicons".
Please run:
npm i favicons
 - or -
yarn add favicons

Error: Could not load the "sharp" module using the darwin-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
    yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=darwin --cpu=x64 sharp
    npm install --force @img/sharp-darwin-x64
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at loadFaviconsLibrary (/var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/index.js:656:11)
    at #generateFaviconsWebapp (/var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/index.js:454:26)
    at #generateFavicons (/var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/index.js:376:44)
    at /var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/index.js:164:42
    at /var/folio/platform-complete/node_modules/favicons-webpack-plugin/src/cache.js:150:5
    at CacheFacade.providePromise (/var/folio/platform-complete/node_modules/webpack/lib/CacheFacade.js:341:24)

This is on MacOS 14.1.2:

$ uname -a
Darwin LP-C02G8208ML85 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64

$ node --version
v18.19.0

Our Jenkins builds on Linux fail with a similar error:

/home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/index.js:656
    throw new Error(
          ^

Error: Could not find the npm peerDependency "favicons".
Please run:
npm i favicons
 - or -
yarn add favicons

Error: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
    yarn add sharp --ignore-engines
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=linux --cpu=x64 sharp
    npm install --force @img/sharp-linux-x64
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at loadFaviconsLibrary (/home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/index.js:656:11)
    at #generateFaviconsWebapp (/home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/index.js:454:26)
    at #generateFavicons (/home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/index.js:376:44)
    at /home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/index.js:164:42
    at /home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/favicons-webpack-plugin/src/cache.js:150:5
    at CacheFacade.providePromise (/home/jenkins/workspace/Automation/build-platform-complete-snapshot/node_modules/webpack/lib/CacheFacade.js:341:24)

Node.js v18.17.1
error Command failed with exit code 1.
BlackEyeByLee commented 11 months ago

sharp@0.33.1: The engine "node" is incompatible with this module. Expected version "^18.17.0 || ^20.3.0 || >=21.0.0".

andy128k commented 11 months ago

Could it be that you have two versions of sharp in a dependency tree?

See also: https://github.com/lovell/sharp/issues/3878 https://github.com/lovell/sharp/issues/3911

zburke commented 11 months ago

The change in nodejs version requirements is related, @BlackEyeByLee, but it's not the full story:

zburke commented 11 months ago

@andy128k, with favicons 7.1.5 the only version of sharp in my tree is 0.33.1:

platform-complete(snapshot)*
$ yarn why sharp
yarn why v1.22.19
[1/4] ๐Ÿค”  Why do we have the module "sharp"...?
[2/4] ๐Ÿšš  Initialising dependency graph...
warning Resolution field "@rehooks/local-storage@2.4.4" is incompatible with requested version "@rehooks/local-storage@^2.4.5"
warning Resolution field "@rehooks/local-storage@2.4.4" is incompatible with requested version "@rehooks/local-storage@^2.4.5"
[3/4] ๐Ÿ”  Finding dependency...
[4/4] ๐Ÿšก  Calculating file sizes...
=> Found "sharp@0.33.1"
info Reasons this module exists
   - "@folio#stripes-cli#@folio#stripes-webpack#favicons" depends on it
   - Hoisted from "@folio#stripes-cli#@folio#stripes-webpack#favicons#sharp"
info Disk size without dependencies: "676KB"
info Disk size with unique dependencies: "1020KB"
info Disk size with transitive dependencies: "1.21MB"
info Number of shared dependencies: 9
โœจ  Done in 1.66s.
andy128k commented 11 months ago

@zburke Did you try what sharp's doc suggests? I mean the link in the error message. It seems you need to fiddle with your package-lock.json (or yarn.lock).

zburke commented 11 months ago

@andy128k, I've looked at those links briefly and will do so more thoroughly but

  1. This problem is not present when favicons is locked to v7.1.4; it's new as of v7.1.5. This suggests the problem is with something in v7.1.5, or in one of its dependencies.
  2. We don't directly depend on sharp; we only receive it as a transitive dependency via favicons, so pursuing the sharp install suggestions seems off-topic in a way since we never issue a yarn install sharp command or anything like it. That said, adding a direct dep on sharp does resolve our problem ๐Ÿคจ , and that's a pretty easy fix for us. I confess, this doesn't entirely make sense to me. Maybe it indicates some brittle logic in our build pipeline that no longer holds up with the new version of sharp though I don't think we are doing anything interesting/clever/stooopid WRT sharp in our build pipeline. Nonetheless, if you want to close this as "can't replicate", I will understand.
nrbernard commented 11 months ago

I also ran into this issue with the new version via the favicons-webpack-plugin package and, for what it's worth, upgrading to Node.js v20.10.0 fixed my build.

lovell commented 11 months ago

yarn why v1.22.19

yarn v1 has been in maintenance mode for almost 4 years. You'll need to add the --ignore-engines flag, as the error message suggests, if you still have to use it. Please upgrade to yarn v3+ if possible.

Please see https://sharp.pixelplumbing.com/install for this information and lots more.

zburke commented 11 months ago

Thanks for weighing in here, @lovell. Again, since our dep on sharp is transitive, we can't add --ignore-engines to our yarn add sharp command because we are not running yarn add sharp. Nonetheless, I understand your point, and am grateful for your guidance. The conclusion I am honing in on amounts to, "favicons v7.1.5, via its updated transitive dep on sharp v0.33.1, dropped compatibility with some old things (node v14, v16, < v18.17; npm v6, v8; yarn v1, v2) that v7.1.4 was compatible with when it used sharp v0.32.6."

That's fine, totally fine, but dropping support is a breaking change, so v7.1.5 really should have been v8.

kleenkanteen commented 6 months ago

If you are using astro, the package @divriots/jampack also has a transitive dependency on sharp. In the build script, remove jampack ./dist to remove it's usage. And remove it from the dev dependencies. Remove sharp from the dependencies list if you have it and update astro to latest version. Don't know which fixed it but now I can deploy to vercel.