cake
cake2mo ago

Convex not able to find sharp in my mono-repo. Looking in wrong `node_modules`.

We're using bun for the package manager / builder of a monorepo with a convex server. We recently added sharp to create some thumbnails inside of convex, and now we're seeing an error:
✖ Error fetching POST http://{domain}/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze utils/fileHandler.js: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
npm install --include=optional sharp
- 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
- Consult the installation documentation:
See https://sharp.pixelplumbing.com/install
✖ Error fetching POST http://{domain}/api/deploy2/start_push 400 Bad Request: InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Uncaught Failed to analyze utils/fileHandler.js: Could not load the "sharp" module using the linux-x64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
npm install --include=optional sharp
- 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
- Consult the installation documentation:
See https://sharp.pixelplumbing.com/install
The error goes , if we symlink the root node_modules into the convex-server dir. This seems likely to be a common problem and I'm curious if there is a better solution to this.
3 Replies
Convex Bot
Convex Bot2mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
djbalin
djbalin2mo ago
sharp must be marked as an external package, see: https://docs.convex.dev/functions/bundling#external-packages Also try to search for "sharp" in this discord, youll find several threads about this package specifically. im having further troubles in my repo thats a pnpm turbo monorepo since the hoisting behavior doesnt play well with external package marking. but in simpler repo setups the link above works just fine!
Bundling | Convex Developer Hub
How Convex bundles and optimizes your function code
cake
cakeOP2mo ago
Thank you!

Did you find this page helpful?