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
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)
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
My answer is not related to deploying functions to firebase, but I had that exact same error:
Error: 'darwin-x64' binaries cannot be used on the 'darwin-arm64v8' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'darwin-arm64v8' platform.
when I tried to run a project with a mac M1 using a version of node that was incompatible.
I tried to run the project with version 16 when the project actually require version <=14.
So if anyone has this problem might be worth checking the node version