Solution of node canvas error reporting in MacOS M1 installation

M1 native does not release binary version of canvas in node15. Therefore, when you install canvas, you will automatically compile from the source code, but if you do not install the corresponding dependency, you will report an error.


arch -arm64 brew install pkg-config cairo pango jpeg giflib librsvg


Homebrew cannot be installed

If you encounter

Error: Failure while executing; `tar --extract --no-same-owner --file /Users/wenbing/Library/Caches/Homebrew/downloads/6f65cc908bca8f42eeb93f33e25d76d748a7a28f20f30f41befe472ea2a01bc5--fribidi-1.0.10.arm64_big_sur.bottle.tar.gz --directory /private/tmp/d20210618-36598-16scyl7` exited with 1. Here's the output:
tar: Error opening archive: Failed to open '/Users/wenbing/Library/Caches/Homebrew/downloads/6f65cc908bca8f42eeb93f33e25d76d748a7a28f20f30f41befe472ea2a01bc5--fribidi-1.0.10.arm64_big_sur.bottle.tar.gz'

For this kind of error reporting, you need to manually install the dependency front dependency first, and then install the module

brew install libtiff gdk-pixbuf librsvg

Node gyp could not find the header file

If your homebrew is also M1 native, then homebrew will be installed under/opt/homebrew. Brew install will be under/opt/homebrew/cell/instead of linking to/usr/local/include. When node gyp is compiled, it is still compiled with clang in essence, and the header file cannot be found, so a fatal error: 'JPEG lib. H' file not found will be reported. The solution is to add/opt/homebrew/cell/to clang’s include path. My practice is in ~ /. Bash_ Add a line to profile

export CPLUS_INCLUDE_PATH=/opt/homebrew/include


Install 0 accounts on Apple M1.

Accounting subjects

Read More: