I just got a new Mac M1 and i am trying to deploy a Firebase Cloud Function. It works fine, as long as I do not include the node canvas module.
When I try to deploy, i am getting the following error:
Error: Error occurred while parsing your function triggers.
Error: dlopen(/Library/WebServer/Documents/inklay_web_cf/functions/node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '/Library/WebServer/Documents/inklay_web_cf/functions/node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/canvas.node' (no such file), '/usr/lib/canvas.node' (no such file)
at tryImporting (pkg/prelude/bootstrap.js:1736:37)
at process.dlopen (pkg/prelude/bootstrap.js:1762:5)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:1186:18)
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)
at Object.<anonymous> (/Library/WebServer/Documents/inklay_web_cf/functions/node_modules/canvas/lib/bindings.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1136:30)
vonnielu@lukass-macbook-pro-1 functions % node-gyp rebuild
zsh: command not found: node-gyp
It seems, that Firebase Cloud Function does not like the architecture. But what can I do? Any help is very welcome.
Node: v16.14.0 Firebase Tools: 10.2.0 Mac OS Monterey: 12.2.1 Apple M1 Max
I resolved the problem by:
Downgrading node version to v12.22.10
Delete all node_modules in my projects folder
Run rosetta terminal in vs-code
npm install
Delete my cloud functions (Deploy with all functions uncommented)
Deploy my cloud functions (firebase deploy)
late answer: facing the same type of issue with an Apple M1 chip (arm64 architecture), I found why my node version was involved:
I'm now looking at 2 options for resolution, either I'm using the previous node in x64, or I find how to get canvas for arm64 / local arch systematically in my package.json (the clean way, imho). (3rd way: new node on x64 but not clean either)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.