Automattic / node-canvas

Node canvas is a Cairo backed Canvas implementation for NodeJS.
10.17k stars 1.17k forks source link

Bundling a prebuild version on Apple M1 fails #2036

Open mn4367 opened 2 years ago

mn4367 commented 2 years ago

I'm trying to create a prebuild bundle of canvas:

This is what I did:

git clone https://github.com/Automattic/node-canvas.git
cd node-canvas
./prebuild/macOS/preinstall.sh      => OK
npm i nan
npm run install
npm run test                        => All tests passed

Then I changed ./prebuild/macOS/bundle.sh to include '-v'

build=build/Release

~/Library/Python/*/bin/macpack build/Release/canvas.node -v -d .

and invoked it. This works and build/Release now contains all the patched libs but if I run npm run test again I just get:

> canvas@2.9.1 test
> mocha test/*.test.js

Killed: 9

Any ideas what is going wrong here? otool -L for canvas.node gives

@loader_path/libpixman-1.0.40.0.dylib (compatibility version 41.0.0, current version 41.0.0)
@loader_path/libcairo.2.dylib (compatibility version 11603.0.0, current version 11603.0.0)
@loader_path/libpng16.16.dylib (compatibility version 54.0.0, current version 54.0.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11)
@loader_path/libpangocairo-1.0.0.dylib (compatibility version 5001.0.0, current version 5001.6.0)
@loader_path/libpango-1.0.0.dylib (compatibility version 5001.0.0, current version 5001.6.0)
@loader_path/libgobject-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.1.0)
@loader_path/libglib-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.1.0)
@loader_path/libintl.8.dylib (compatibility version 11.0.0, current version 11.0.0)
@loader_path/libharfbuzz.0.dylib (compatibility version 40201.0.0, current version 40201.0.0)
@loader_path/libfreetype.6.dylib (compatibility version 25.0.0, current version 25.2.0)
@loader_path/libjpeg.9.dylib (compatibility version 15.0.0, current version 15.0.0)
@loader_path/libgif.7.2.0.dylib (compatibility version 0.0.0, current version 7.2.0)
@loader_path/librsvg-2.2.dylib (compatibility version 51.0.0, current version 51.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.0.0)
@loader_path/libgio-2.0.0.dylib (compatibility version 7201.0.0, current version 7201.1.0)
@loader_path/libgdk_pixbuf-2.0.0.dylib (compatibility version 4201.0.0, current version 4201.8.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1200.3.0)

so this seems to be OK (from what I read the missing entries from /usr/lib/ no longer exist physically on newer versions of macOS but are loaded from a cache).

I would also like to take the opportunity to kindly ask for pre-built builds to be made available for Apple M1, thank you! I'm willing to help, but my knowledge in this area is very sparse.

Just for completeness the outputs of ./prebuild/macOS/bundle.sh and npm run install are listed below.


./prebuild/macOS/bundle.sh:

Some of the paths in the dependency tree could not be resolved
Maybe you already bundled canvas.node?
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libc++.1.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libiconv.2.dylib
Could not resolve /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
Could not resolve /usr/lib/libobjc.A.dylib
Could not resolve /usr/lib/libiconv.2.dylib
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
Could not resolve /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /usr/lib/libbz2.1.0.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /usr/lib/libxml2.2.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libobjc.A.dylib
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
Could not resolve /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Could not resolve /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
Could not resolve /usr/lib/libresolv.9.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
Could not resolve /usr/lib/libobjc.A.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libexpat.1.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libz.1.dylib
Could not resolve /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Could not resolve /usr/lib/libSystem.B.dylib
Patching build/Release/canvas.node
31 total non-system dependencies
libpixman-1.0.40.0.dylib
-> libpixman-1.0.40.0.dylib
libcairo.2.dylib
-> libcairo.2.dylib
-> libpixman-1.0.40.0.dylib
-> libfontconfig.1.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
-> libxcb-shm.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libxcb-render.0.0.0.dylib
-> libXrender.1.dylib
-> libX11.6.dylib
-> libXext.6.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libpng16.16.dylib
-> libpng16.16.dylib
libpangocairo-1.0.0.dylib
-> libpangocairo-1.0.0.dylib
-> libpango-1.0.0.dylib
-> libpangoft2-1.0.0.dylib
-> libglib-2.0.0.dylib
-> libgobject-2.0.0.dylib
-> libharfbuzz.0.dylib
-> libfontconfig.1.dylib
-> libcairo.2.dylib
-> libpixman-1.0.40.0.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
-> libxcb-shm.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libxcb-render.0.0.0.dylib
-> libXrender.1.dylib
-> libX11.6.dylib
-> libXext.6.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
-> libgraphite2.3.2.1.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
-> libintl.8.dylib
-> libgio-2.0.0.dylib
-> libgmodule-2.0.0.dylib
-> libfribidi.0.dylib
libpango-1.0.0.dylib
-> libpango-1.0.0.dylib
-> libglib-2.0.0.dylib
-> libgobject-2.0.0.dylib
-> libgio-2.0.0.dylib
-> libfribidi.0.dylib
-> libharfbuzz.0.dylib
-> libfreetype.6.dylib
-> libgraphite2.3.2.1.dylib
-> libpng16.16.dylib
-> libgmodule-2.0.0.dylib
-> libintl.8.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
libgobject-2.0.0.dylib
-> libgobject-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
-> libintl.8.dylib
libglib-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libpcre.1.dylib
-> libintl.8.dylib
libintl.8.dylib
-> libintl.8.dylib
libharfbuzz.0.dylib
-> libharfbuzz.0.dylib
-> libfreetype.6.dylib
-> libgraphite2.3.2.1.dylib
-> libglib-2.0.0.dylib
-> libpcre.1.dylib
-> libintl.8.dylib
-> libpng16.16.dylib
libfreetype.6.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
libjpeg.9.dylib
-> libjpeg.9.dylib
libgif.7.2.0.dylib
-> libgif.7.2.0.dylib
librsvg-2.2.dylib
-> librsvg-2.2.dylib
-> libpng16.16.dylib
-> libcairo-gobject.2.dylib
-> libgdk_pixbuf-2.0.0.dylib
-> libgio-2.0.0.dylib
-> libpangocairo-1.0.0.dylib
-> libcairo.2.dylib
-> libpangoft2-1.0.0.dylib
-> libpango-1.0.0.dylib
-> libgobject-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libintl.8.dylib
-> libharfbuzz.0.dylib
-> libfontconfig.1.dylib
-> libfreetype.6.dylib
-> libgraphite2.3.2.1.dylib
-> libpcre.1.dylib
-> libffi.8.dylib
-> libfribidi.0.dylib
-> libpixman-1.0.40.0.dylib
-> libxcb-shm.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libxcb-render.0.0.0.dylib
-> libXrender.1.dylib
-> libX11.6.dylib
-> libXext.6.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
-> libgmodule-2.0.0.dylib
-> libjpeg.9.dylib
libgio-2.0.0.dylib
-> libgio-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libgobject-2.0.0.dylib
-> libgmodule-2.0.0.dylib
-> libintl.8.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
libgdk_pixbuf-2.0.0.dylib
-> libgdk_pixbuf-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libintl.8.dylib
-> libgobject-2.0.0.dylib
-> libgmodule-2.0.0.dylib
-> libgio-2.0.0.dylib
-> libpng16.16.dylib
-> libjpeg.9.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
libgmodule-2.0.0.dylib
-> libgmodule-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libpcre.1.dylib
-> libintl.8.dylib
libcairo-gobject.2.dylib
-> libcairo-gobject.2.dylib
-> libcairo.2.dylib
-> libpixman-1.0.40.0.dylib
-> libfontconfig.1.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
-> libxcb-shm.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libxcb-render.0.0.0.dylib
-> libXrender.1.dylib
-> libX11.6.dylib
-> libXext.6.dylib
-> libgobject-2.0.0.dylib
-> libglib-2.0.0.dylib
-> libintl.8.dylib
-> libpcre.1.dylib
-> libffi.8.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libpangoft2-1.0.0.dylib
-> libpangoft2-1.0.0.dylib
-> libpango-1.0.0.dylib
-> libglib-2.0.0.dylib
-> libgobject-2.0.0.dylib
-> libgio-2.0.0.dylib
-> libharfbuzz.0.dylib
-> libfontconfig.1.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
-> libgraphite2.3.2.1.dylib
-> libgmodule-2.0.0.dylib
-> libintl.8.dylib
-> libffi.8.dylib
-> libpcre.1.dylib
-> libfribidi.0.dylib
libfontconfig.1.dylib
-> libfontconfig.1.dylib
-> libfreetype.6.dylib
-> libpng16.16.dylib
libxcb-shm.0.0.0.dylib
-> libxcb-shm.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libxcb.1.1.0.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libxcb-render.0.0.0.dylib
-> libxcb-render.0.0.0.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libXrender.1.dylib
-> libXrender.1.dylib
-> libX11.6.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libX11.6.dylib
-> libX11.6.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libXext.6.dylib
-> libXext.6.dylib
-> libX11.6.dylib
-> libxcb.1.1.0.dylib
-> libXau.6.dylib
-> libXdmcp.6.dylib
libXau.6.dylib
-> libXau.6.dylib
libXdmcp.6.dylib
-> libXdmcp.6.dylib
libgraphite2.3.2.1.dylib
-> libgraphite2.3.2.1.dylib
libpcre.1.dylib
-> libpcre.1.dylib
libffi.8.dylib
-> libffi.8.dylib
libfribidi.0.dylib
-> libfribidi.0.dylib

canvas.node + 31 dependencies successfully patched

npm run install:

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.9
node-pre-gyp info using node@16.13.0 | darwin | arm64
node-pre-gyp info check checked for "/Users/mn/Desktop/canvas/node-canvas/build/Release/canvas.node" (not found)
node-pre-gyp http GET https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v93-darwin-unknown-arm64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v93-darwin-unknown-arm64.tar.gz 
node-pre-gyp WARN Pre-built binaries not installable for canvas@2.9.1 and node@16.13.0 (node-v93 ABI, unknown) (falling back to source compile with node-gyp) 
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v93-darwin-unknown-arm64.tar.gz 
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@16.13.0 | darwin | arm64
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@16.13.0 | darwin | arm64
gyp info find Python using Python version 3.9.12 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
gyp info spawn args [
gyp info spawn args   '/Users/mn/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/mn/Desktop/canvas/node-canvas/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/mn/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/mn/Library/Caches/node-gyp/16.13.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/mn/Library/Caches/node-gyp/16.13.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/mn/.nvm/versions/node/v16.13.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/mn/Library/Caches/node-gyp/16.13.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/mn/Desktop/canvas/node-canvas',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok 
gyp info it worked if it ends with ok
gyp info using node-gyp@8.2.0
gyp info using node@16.13.0 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  SOLINK_MODULE(target) Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/backend/Backend.o
In file included from ../src/backend/Backend.cc:1:
../src/backend/Backend.h:60:14: warning: private field 'backend' is not used [-Wunused-private-field]
    Backend* backend;
             ^
1 warning generated.
  CXX(target) Release/obj.target/canvas/src/backend/ImageBackend.o
  CXX(target) Release/obj.target/canvas/src/backend/PdfBackend.o
  CXX(target) Release/obj.target/canvas/src/backend/SvgBackend.o
  CXX(target) Release/obj.target/canvas/src/bmp/BMPParser.o
  CXX(target) Release/obj.target/canvas/src/Backends.o
  CXX(target) Release/obj.target/canvas/src/Canvas.o
  CXX(target) Release/obj.target/canvas/src/CanvasGradient.o
  CXX(target) Release/obj.target/canvas/src/CanvasPattern.o
  CXX(target) Release/obj.target/canvas/src/CanvasRenderingContext2d.o
  CXX(target) Release/obj.target/canvas/src/closure.o
  CXX(target) Release/obj.target/canvas/src/color.o
  CXX(target) Release/obj.target/canvas/src/Image.o
../src/Image.cc:1164:3: warning: 'rsvg_handle_get_dimensions' is deprecated: Use 'rsvg_handle_get_intrinsic_size_in_pixels' instead [-Wdeprecated-declarations]
  rsvg_handle_get_dimensions(_rsvg, dims);
  ^
/opt/homebrew/Cellar/librsvg/2.54.1/include/librsvg-2.0/librsvg/rsvg.h:705:1: note: 'rsvg_handle_get_dimensions' has been explicitly marked deprecated here
RSVG_DEPRECATED_FOR(rsvg_handle_get_intrinsic_size_in_pixels)
^
/opt/homebrew/Cellar/librsvg/2.54.1/include/librsvg-2.0/librsvg/rsvg.h:50:32: note: expanded from macro 'RSVG_DEPRECATED_FOR'
#define RSVG_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) RSVG_API
                               ^
/opt/homebrew/Cellar/glib/2.72.1/include/glib-2.0/glib/gmacros.h:1113:44: note: expanded from macro 'G_DEPRECATED_FOR'
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
                                           ^
../src/Image.cc:1203:24: warning: 'rsvg_handle_render_cairo' is deprecated: Use 'rsvg_handle_render_document' instead [-Wdeprecated-declarations]
  gboolean render_ok = rsvg_handle_render_cairo(_rsvg, cr);
                       ^
/opt/homebrew/Cellar/librsvg/2.54.1/include/librsvg-2.0/librsvg/rsvg-cairo.h:87:1: note: 'rsvg_handle_render_cairo' has been explicitly marked deprecated here
RSVG_DEPRECATED_FOR(rsvg_handle_render_document)
^
/opt/homebrew/Cellar/librsvg/2.54.1/include/librsvg-2.0/librsvg/rsvg.h:50:32: note: expanded from macro 'RSVG_DEPRECATED_FOR'
#define RSVG_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f) RSVG_API
                               ^
/opt/homebrew/Cellar/glib/2.72.1/include/glib-2.0/glib/gmacros.h:1113:44: note: expanded from macro 'G_DEPRECATED_FOR'
#define G_DEPRECATED_FOR(f) __attribute__((__deprecated__("Use '" #f "' instead")))
                                           ^
2 warnings generated.
  CXX(target) Release/obj.target/canvas/src/ImageData.o
  CXX(target) Release/obj.target/canvas/src/init.o
  CXX(target) Release/obj.target/canvas/src/register_font.o
  SOLINK_MODULE(target) Release/canvas.node
gyp info ok 
node-pre-gyp info ok 
mn4367 commented 2 years ago

I checked today again: the same happens on macOS 12.4 (Monterey).

Do other users see the same behavior?

ihmpavel commented 2 years ago

Hi, I am experiencing the same issue on macOS 12.4 (Monterey). After installing, it tries to fetch non-existing binary from https://github.com/Automattic/node-canvas/releases/download/v2.9.1/canvas-v2.9.1-node-v93-darwin-unknown-arm64.tar.gz (same as yours). Unfortunately there is no sign of that release on the release page https://github.com/Automattic/node-canvas/releases

Because I do not have proper tools, node-gyp fails and package is not installed properly.

Edit: Rewritten

mn4367 commented 2 years ago

@ihmpavel Sorry, no, it's not a shame and it's not unusable. It's open source, comes for free, works very well (provided, some dev tools are installed on an M1 machine, which is very easy to do) so I am indeed very grateful to the authors. And I doubt that it motivates the authors to look at the problem if this kind of language is used...

The only problem I have is that I can't pre-pack a version of my software with pkg or Electron and ship that to darwin-arm64 users.

ihmpavel commented 2 years ago

@mn4367

Unfortunately it was bad wording I used... (After translating it is a different meaning than I anticipated.) I did not want to be rude or make someone sad, angry for what are they doing for to the OSS community.

I really appreciate OSS and I am very grateful for anything that is available to use and explore. What I wanted to say, but I wrote it wrongly is: That it is pity, that there are no prebuilt binaries to use for anybody to just install, hop in, use, enjoy, help others with issues, create PR and make it better.

I know there are a lot of combinations of architectures, operating system that it is almost impossible to prebuild for all of them. (Also I know there are some architecture problems with Github actions for prebuilding all possible combinations.)

I am not familiar with building native apps on M1 (with Github Actions configuration to make them working and to be available to everyone who is using M1 or M2 macs), otherwise I have already sent a PR instead of writing comment.

I am also very happy that there are instructions for building it natively on the platform.

To sum it up I would be very happy to contribute if I understand it correctly and someone can benefit from that. (I wanted to tell you, that you are not alone on MacBook with this issue, but others are experiencing it also.)

(I have rewritten the initial comment.)

mn4367 commented 2 years ago

@ihmpavel, ok thanks, much better now :-)

conigs commented 2 years ago

Getting the same error. It looks like there's a release for canvas-v2.9.3-node-v102-darwin-unknown-arm64.tar.gz, but the installer is calling canvas-v2.9.3-node-v93-darwin-unknown-arm64.tar.gz instead which is non-existent, throwing a 404 error.

FontEndArt commented 2 years ago

得到同样的错误。看起来有一个版本canvas-v2.9.3-node-v102-darwin-unknown-arm64.tar.gz,但安装程序正在调用canvas-v2.9.3-node-v93-darwin-unknown-arm64.tar.gz它,它不存在,引发 404 错误。

https://github.com/Automattic/node-canvas/issues/1733

虽然我也遇到了同样的问题,但是我依靠它解决了,在自己 Mac 上安装了一些插件! Although I also encountered the same problem, I solved it by relying on it and installed some plugins on my Mac.

SaraChicaD commented 1 year ago

this is what fixed it for me: https://github.com/Automattic/node-canvas/issues/1733#issuecomment-761703018

Kaisarion commented 1 year ago

i'm using a docker on an M1. i ran the apt install with the correct dependency names to no avail. is it an alternate command?

jjmiranda commented 1 year ago

Execute this in your zsh: arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg

and run npm install ;)

Peter-MJ-Parker commented 1 year ago

I have found a fix for Apple M1 and M2 users! Install pre-requisites

CharlesCCC commented 1 year ago

thank you @Peter-MJ-Parker for provide the link, that helped.

For Apple M chips , the key is to install the ARM version of those package by running arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg then you should able to just node install canvas

m4nuC commented 8 months ago

https://github.com/Automattic/node-canvas/issues/2036#issuecomment-1611284426 that did it for me !