I'm getting the following error on Mac with M1 CPU:
I'm unable to build nodejs app with 'node-canvas' npm package, because Error: dlopen(/Users/..../node_modules/canvas/build/Release/canvas.node, 0x0001): tried: '/Users/..../node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/..../node_modules/canvas/build/Release/canvas.node' (no such file), '/Users/..../node_modules/canvas/build/Release/canvas.node' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
I installed brew canvas dependencies:
brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman
I also set following path:
export PKG_CONFIG_PATH="/opt/homebrew/opt/pixman/lib/pkgconfig"
I also tried to rebuild from source-codes:
npm install --build-from-source
I also removed and installed again canvas package:
rm -rf node_modules package-lock.json npm install
But still I'm getting the same error related to arm64
architecture.
notice:
nodejs is installed with nvm
nodejs version: v22.11.0
nvm version: 0.39.7
Thanks for help.