Closed Przemoo16 closed 5 months ago
HI @Przemoo16 is it related to this one https://github.com/lovell/sharp/issues/3870 ? I'm trying to figure out the exact way to solve the issue.
Hi @gioboa, yes, the issue seems to be the same, however I'm not using Vercel but they mentioned it is only related to the Vercel environment.
@Przemoo16 can you try adding
"optionalDependencies": {
"@img/sharp-linux-x64": "^0.33.0"
},
to your package.json?
Yarn: 1.22.21 - ~/.nvm/versions/node/v20.5.1/bin/yarn
https://sharp.pixelplumbing.com/install
# yarn v1 (maintenance mode)
yarn add sharp --ignore-engines
(yarn v1 has been in maintenance mode for almost 4 years, please upgrade.)
Yarn: 1.22.21 - ~/.nvm/versions/node/v20.5.1/bin/yarn
https://sharp.pixelplumbing.com/install
# yarn v1 (maintenance mode) yarn add sharp --ignore-engines
(yarn v1 has been in maintenance mode for almost 4 years, please upgrade.)
Thanks for the reply. This seems to solve the issue. However, I don't want to specify the sharp
as my app dependency. This is a dependency that comes from the Qwik so I'd expect that the engines are ignored at the Qwik level.
i have the same issue yarn1 and latest pnpm. pnpm sometimes works but rm -rf node_modules, pnpm install, at this moment does not work for me. Ubuntu 22.04.3 LTS node v20.10.0 nvm 0.38.0
for me solution is: "postinstall": "pnpm install sharp"
I have the same error but with pnpm, any solution?
@Przemoo16 can you try adding
"optionalDependencies": { "@img/sharp-linux-x64": "^0.33.0" },
to your package.json?
works
Next person with issues please try pnpm dedupe, or when using npm, making sure it's npm>v9.6.5
Next person with issues please try pnpm dedupe, or when using npm, making sure it's npm>v9.6.5
I did the pnpm dedupe but it didn't work and I added the above in my package.json
"optionalDependencies": {
"@img/sharp-darwin-arm64": "^0.33.0"
},
The relevant issue for npm
is here: https://github.com/npm/cli/issues/4828
Other package managers might have similar issues.
The list of optional dependencies that sharp needs at least one of is this: https://github.com/lovell/sharp/blob/c5eaeb2ddbef7fa74fb682c8dc774156d084c053/package.json#L143-L163
@lovell pinging you for visibility but I'm not sure you can do anything on your end? Or do you know of something specific we could do when the starter project is created?
sharp v0.33.0 onwards has intentionally switched to use exactly the same installation approach as esbuild, rollup, swc etc. and take advantage of features made available in all modern JS package managers. This allows people to select their choice of package manager, and in doing so therefore accept any bugs their choice of package manager might contain.
I've attempted to improve the messaging in sharp via commit https://github.com/lovell/sharp/commit/3a0c37569219d10321f559fc63715ef45aca0c0d but the summary here is that npm
is currently the wrong choice of package manager if you want multi-platform support.
npm i --package-lock=false
worked for me.
package-lock Default: true Type: Boolean If set to false, then ignore package-lock.json files when installing. This will also prevent writing package-lock.json if save is true.
@DeVoresyah you have an issue with Cloudflare and sharp, right?
@DeVoresyah you have an issue with Cloudflare and sharp, right?
yes, here's my detail:
Build command: bun run build
Build output directory: /dist
Build system version: 2 (latest)
Root directory: /
Environment variables: None
bun
2023-12-15T07:33:21.472815Z Cloning repository...
2023-12-15T07:33:22.736409Z From https://github.com/Cuan-sh/cuan-landing
2023-12-15T07:33:22.737926Z * branch f969cdbb95f1e9e6c0a46a15f87589446a83e26b -> FETCH_HEAD
2023-12-15T07:33:22.738284Z
2023-12-15T07:33:22.884326Z HEAD is now at f969cdb fix: remove sharp
2023-12-15T07:33:22.884966Z
2023-12-15T07:33:22.98129Z
2023-12-15T07:33:23.011128Z Success: Finished cloning repository files
2023-12-15T07:33:23.748422Z Detected the following tools from environment: nodejs@16.20.2, bun@1.0.1
2023-12-15T07:33:23.749321Z Installing nodejs 16.20.2
2023-12-15T07:33:23.832509Z nodejs 16.20.2 is already installed
2023-12-15T07:33:24.404676Z Installing project dependencies: bun install --frozen-lockfile
2023-12-15T07:33:24.666856Z bun install v1.0.1 (31aec4eb)
2023-12-15T07:33:35.150443Z + @img/sharp-linux-x64@0.33.0
2023-12-15T07:33:35.150862Z + @builder.io/qwik@1.2.17
2023-12-15T07:33:35.151007Z + @builder.io/qwik-city@1.2.17
2023-12-15T07:33:35.151123Z + @storybook/addon-essentials@7.5.3
2023-12-15T07:33:35.151234Z + @storybook/addon-links@7.5.3
2023-12-15T07:33:35.151351Z + @storybook/blocks@7.5.3
2023-12-15T07:33:35.151464Z + @storybook/builder-vite@7.5.3
2023-12-15T07:33:35.151572Z + @storybook/html@7.5.3
2023-12-15T07:33:35.15169Z + @storybook/html-vite@7.5.3
2023-12-15T07:33:35.151798Z + @types/eslint@8.44.7
2023-12-15T07:33:35.151905Z + @types/node@20.9.0
2023-12-15T07:33:35.152019Z + @typescript-eslint/eslint-plugin@6.11.0
2023-12-15T07:33:35.152147Z + @typescript-eslint/parser@6.11.0
2023-12-15T07:33:35.152256Z + autoprefixer@10.4.16
2023-12-15T07:33:35.15237Z + eslint@8.53.0
2023-12-15T07:33:35.152508Z + eslint-plugin-qwik@1.2.17
2023-12-15T07:33:35.152648Z + postcss@8.4.31
2023-12-15T07:33:35.152765Z + prettier@3.1.0
2023-12-15T07:33:35.152875Z + prettier-plugin-tailwindcss@0.5.7
2023-12-15T07:33:35.153004Z + storybook@7.5.3
2023-12-15T07:33:35.153118Z + storybook-framework-qwik@0.2.4
2023-12-15T07:33:35.153227Z + tailwindcss@3.3.3
2023-12-15T07:33:35.153367Z + typescript@5.2.2
2023-12-15T07:33:35.153482Z + undici@5.27.2
2023-12-15T07:33:35.153606Z + vite@4.5.0
2023-12-15T07:33:35.153723Z + vite-tsconfig-paths@4.2.1
2023-12-15T07:33:35.153832Z + wrangler@3.20.0
2023-12-15T07:33:35.153953Z + @fontsource-variable/inter@5.0.15
2023-12-15T07:33:35.154068Z + @qwikest/icons@0.0.13
2023-12-15T07:33:35.154177Z + remixicon@3.5.0
2023-12-15T07:33:35.154291Z
2023-12-15T07:33:35.154401Z 1123 packages installed [10.49s]
2023-12-15T07:33:35.179559Z Executing user command: bun run build
2023-12-15T07:33:35.480493Z $ qwik build
2023-12-15T07:33:35.804543Z
2023-12-15T07:33:35.805033Z ............
2023-12-15T07:33:35.805263Z .::: :--------:.
2023-12-15T07:33:35.805479Z .:::: .:-------:.
2023-12-15T07:33:35.805636Z .:::::. .:-------.
2023-12-15T07:33:35.80584Z ::::::. .:------.
2023-12-15T07:33:35.805988Z ::::::. :-----:
2023-12-15T07:33:35.806195Z ::::::. .:-----.
2023-12-15T07:33:35.806326Z :::::::. .-----.
2023-12-15T07:33:35.806449Z ::::::::.. ---:.
2023-12-15T07:33:35.806651Z .:::::::::. :-:.
2023-12-15T07:33:35.806786Z ..::::::::::::
2023-12-15T07:33:35.806896Z ...::::
2023-12-15T07:33:35.807173Z
2023-12-15T07:33:35.807349Z
2023-12-15T07:33:35.8075Z
2023-12-15T07:33:35.807627Z bun run build.types
2023-12-15T07:33:35.807756Z bun run build.client
2023-12-15T07:33:35.807883Z bun run build.server
2023-12-15T07:33:35.808001Z bun run lint
2023-12-15T07:33:35.808135Z
2023-12-15T07:33:35.817122Z $ tsc --incremental --noEmit --pretty
2023-12-15T07:33:35.832806Z $ vite build
2023-12-15T07:33:36.708088Z [31merror during build:
2023-12-15T07:33:36.708443Z Error:
2023-12-15T07:33:36.708578Z Something went wrong installing the "sharp" module
2023-12-15T07:33:36.708735Z
2023-12-15T07:33:36.708846Z Cannot find module '../build/Release/sharp-linux-x64.node'
2023-12-15T07:33:36.708954Z Require stack:
2023-12-15T07:33:36.709062Z - /opt/buildhome/repo/node_modules/sharp/lib/sharp.js
2023-12-15T07:33:36.70917Z - /opt/buildhome/repo/node_modules/sharp/lib/constructor.js
2023-12-15T07:33:36.709277Z - /opt/buildhome/repo/node_modules/sharp/lib/index.js
2023-12-15T07:33:36.709386Z
2023-12-15T07:33:36.709503Z Possible solutions:
2023-12-15T07:33:36.70961Z - Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
2023-12-15T07:33:36.709732Z - Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
2023-12-15T07:33:36.709839Z - Consult the installation documentation: https://sharp.pixelplumbing.com/install
2023-12-15T07:33:36.709951Z at Object.<anonymous> (/opt/buildhome/repo/node_modules/sharp/lib/sharp.js:37:9)
2023-12-15T07:33:36.710058Z at Module._compile (node:internal/modules/cjs/loader:1198:14)
2023-12-15T07:33:36.710172Z at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
2023-12-15T07:33:36.710286Z at Module.load (node:internal/modules/cjs/loader:1076:32)
2023-12-15T07:33:36.710398Z at Function.Module._load (node:internal/modules/cjs/loader:911:12)
2023-12-15T07:33:36.710516Z at Module.require (node:internal/modules/cjs/loader:1100:19)
2023-12-15T07:33:36.710632Z at require (node:internal/modules/cjs/helpers:119:18)
2023-12-15T07:33:36.71075Z at Object.<anonymous> (/opt/buildhome/repo/node_modules/sharp/lib/constructor.js:11:1)
2023-12-15T07:33:36.713258Z at Module._compile (node:internal/modules/cjs/loader:1198:14)
2023-12-15T07:33:36.713453Z at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10)[39m
2023-12-15T07:33:36.734319Z error: script "build.client" exited with code 1 (SIGHUP)
2023-12-15T07:33:36.742193Z error: script "build" exited with code 1 (SIGHUP)
2023-12-15T07:33:36.744367Z Failed: Error while executing user command. Exited with error code: 1
2023-12-15T07:33:39.331625Z Failed: build command exited with code: 1
2023-12-15T07:33:40.213682Z Failed: error occurred while running build command
hi @gioboa, for my case I think it's my mistake because not upgrading all qwik dependencies to the latest. I found the root cause when opening the issue in sharp repo (https://github.com/lovell/sharp/issues/3896).
So, I tried to upgrade to qwik latest wich is 1.3.0
and it's solved the issue
facing the same issue on cloudflare pages build pipeline
I added the optional deps to my package.json. I'm using latest npm. works on my machine now both mac/linux packages are downloaded and in github actions I still have npm ci and it uses the correct optional package
"optionalDependencies": {
"@img/sharp-linux-x64": "^0.33.0",
"@rollup/rollup-linux-x64-gnu": "^4.9.0"
}
On macos 14.1.1, I run pnpm install --force @img/sharp-darwin-x64
and it works.
Not ideal but fixed adding "postinstall": "pnpm install --force @img/sharp-darwin-x64"
to package.json (for cloudflare).
For me, using Mac M1, adding the following to package.json
:
"optionalDependencies": {
"@img/sharp-darwin-arm64": "^0.33.1"
}
Then, pnpm dedupe
solved the problem.
Please all note that sharp is only working on "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
, which means that its optional binary dependencies won't be installed on other node versions. Node 16 is not an option.
https://github.com/lovell/sharp/blob/a77ac6ae259908a989d6c73e70f19d6994b7a237/package.json#L189
btw, I believe yarn v1 isn't compatible with sharp module. We had to upgrade to yarn v4 (I guess yarn v2+ would work as well).
@wmertens Thanks, you've inspired me to add a runtime version check via commit https://github.com/lovell/sharp/commit/45e8071599772f320d0d8314fedf0b13b0592d28
@nelsonprsousa #5556 (comment)
We tried with that as well. I believe the problem was with the Dockerfile using yarn v1.
But yeah, no longer using v1. No point really in using v1 in 2024
This 'sharp' issue is stopping me from deploying to netlify....! cannot find a solution online.. I wonder why the framework authors do not add steps to get it right.???
When built on Cloudflare, setting up node to 18+ will resolve the error.
I added a file .node-version
at the root,
18
to instruct CL to build against that version.
When built on Cloudflare, setting up node to 18+ will resolve the error.
I added a file
.node-version
at the root,18
to instruct CL to build against that version.
Thank you.. I will try and will update later
closing since we require node 18 now
Summary
This issue is due to
npm
not storing optional platform-dependent dependencies in the lockfile (see issue), so that using the lockfile on another platform fails.pnpm
doesn't seem to have a problem with it.Leaving this open for visibility.
Which component is affected?
Qwik Runtime
Describe the bug
After updating Qwik to the latest version, I'm getting the following error when trying to build an app:
It could be related to this issue: https://github.com/lovell/sharp/issues/3870
Reproduction
https://github.com/Przemoo16/qwik-bug
Steps to reproduce
yarn create qwik
yarn build
System Info
Additional Information
No response