If packaging for cross platform electron, do I need to run npm install for both types of Mac CPU?
Question about an existing feature
What are you trying to achieve?
I want to use sharp in an electron application. I want to build this application to work for all platforms (Mac arm64, Mac x64 and Linux - Windows happens differently, of course).
I manage my dependencies using yarn, but I've noticed that the built application errors on arm64 unless I do this with npm:
npm install --cpu=arm64 --os=darwin sharp
This seems to create extra modules in node_modules, which then get packaged up in the app and it all works.
BUT: if I do that, then I can't seem to get a build working for x64. So do I need to run this as well?:
npm install --cpu=x64 --os=darwin sharp
When you searched for similar issues, what did you find that might be related?
I searched for similar issues, but couldn't find appropriate ones. I read the installation instructions (https://sharp.pixelplumbing.com/install#cross-platform), though I'm still not entirely clear, given that it says you should just be able to yarn add sharp and then make sure the two modules are in the asarUnpack section, but that still doesn't work.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this question
N/A
Please provide sample image(s) that help explain this question
N/A
Thanks for any/all help!
PS: This library is fantastic. I switched over from Jimp and this is just on another level in terms of speed of processing and ease of use. 👏
For multi-platform support within the same installation tree you probably want to use the supportedArchitectures feature of yarn v3+ or pnpm (i.e. npm is inappropriate).
https://sharp.pixelplumbing.com/install#cross-platform
@ndtreviv Were you able to make progress with this?
@ndtreviv Were you able to make progress with this?
Alas, we're on a really old version of yarn. I've made a note of it and hopefully we can fix it properly in future.
Thanks for your help.