Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform

I am trying to deploy functions to firebase using my Mac M1, for which it was required to do an npm install to install packages in node_modules/. I am getting this error:

Error: 'darwin-arm64v8' binaries cannot be used on the 'darwin-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-x64' platform.
    at Object.hasVendoredLibvips (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/libvips.js:80:13)
    at Object.<anonymous> (/Users/ali/Desktop/tajir/backend-mvp/appengine/back-end-flex/node_modules/sharp/lib/constructor.js:7:22)
    at Module._compile (internal/modules/cjs/loader.js:1136:30)
    at Module._compile (pkg/prelude/bootstrap.js:1394:32)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:10)
    at Module.load (internal/modules/cjs/loader.js:984:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1024:19)
    at Module.require (pkg/prelude/bootstrap.js:1338:31)
    at require (internal/modules/cjs/helpers.js:72:18)

like image 524
Ali Sajjad Avatar asked Jan 19 '26 22:01

Ali Sajjad


2 Answers

Usually someone having a Mac M1 would have this issue. The Mac M1 processor is arm64. There was a solution posted here which requires to change terminal architecture to arch -x86_64 zsh which I did not want to do.

So, that's the workaround I was able to discover (some of the steps also mentioned in the error):

rm -rf node_modules/sharp
npm install --arch=x64 --platform=darwin sharp
like image 81
Ali Sajjad Avatar answered Jan 22 '26 11:01

Ali Sajjad


this works for me

https://sharp.pixelplumbing.com/install

npm install --platform=darwin --arch=x64 sharp
npm rebuild --platform=darwin --arch=arm64 sharp
like image 30
xiaotian Avatar answered Jan 22 '26 11:01

xiaotian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!