詳細記錄一次npm i canvas報錯的解決過程

JaysonHwang發表於2019-02-08

npm i canvas 報錯資訊

$ npm i canvas

> canvas@1.6.13 install /Users/jayson/Documents/workspace/xuebang/question-bank-front_uat_20181026/node_modules/canvas
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
./util/has_lib.sh: line 31: pkg-config: command not found
gyp: Call to `./util/has_lib.sh freetype` returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jayson/Documents/workspace/xuebang/question-bank-front_uat_20181026/node_modules/canvas
gyp ERR! node -v v10.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.13 (node_modules/canvas):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.13 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

up to date in 9.553s
複製程式碼

brew install pkg-config

注意到:pkg-config: command not found這個報錯,是說作業系統上少了這個命令。參考Can`t install rmagick, pkg-config: command not found這篇文章。(對於macos系統來說),主要是執行一下命令:

brew uninstall pkg-config
brew install pkg-config
brew unlink pkg-config && brew link pkg-config
複製程式碼

詳細執行過程記錄:

$ brew install pkg-config
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
arangodb                   awscli                     binaryen                   ompl                       scala

==> Downloading https://homebrew.bintray.com/bottles/pkg-config-0.29.2.sierra.bottle.tar.gz
Already downloaded: /Users/jayson/Library/Caches/Homebrew/downloads/c66b3ea1aa568233b601c4df3026803081d97cc5f1e11f92a1b3c04588e45678--pkg-config-0.29.2.sierra.bottle.tar.gz
==> Pouring pkg-config-0.29.2.sierra.bottle.tar.gz
?  /usr/local/Cellar/pkg-config/0.29.2: 11 files, 627.1KB
複製程式碼

記得把pkg-config的路徑新增到.bash_profile到path中:

export PKG_CONFIG_PATH = /usr/local/Cellar/pkg-config/0.29.2/
export PATH=$PKG_CONFIG_PATH/bin:$PATH
複製程式碼

再嘗試 npm i canvas 報錯資訊

這次報以下錯誤:

$ npm i canvas

> canvas@1.6.13 install /Users/jayson/Documents/workspace/xuebang/question-bank-front_uat_20181026/node_modules/canvas
> node-gyp rebuild

gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc`
to the PKG_CONFIG_PATH environment variable
No package `cairo` found
gyp: Call to `./util/has_lib.sh freetype` returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:182:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:240:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/jayson/Documents/workspace/xuebang/question-bank-front_uat_20181026/node_modules/canvas
gyp ERR! node -v v10.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.13 (node_modules/canvas):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.13 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

up to date in 9.059s
複製程式碼

brew install cairo

參考這篇文章npm install canvas簡明指南
注意到:to the PKG_CONFIG_PATH environment variable No package `cairo` found這個報錯,cairo可以通過homebrew安裝,詳細記錄如下:

$ brew install cairo
==> Installing dependencies for cairo: libpng, freetype, fontconfig, gettext, libffi, glib and pixman
==> Installing cairo dependency: libpng
==> Downloading https://homebrew.bintray.com/bottles/libpng-1.6.35.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.6.35.sierra.bottle.tar.gz
?  /usr/local/Cellar/libpng/1.6.35: 26 files, 1.2MB
==> Installing cairo dependency: freetype
==> Downloading https://homebrew.bintray.com/bottles/freetype-2.9.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring freetype-2.9.1.sierra.bottle.tar.gz
?  /usr/local/Cellar/freetype/2.9.1: 60 files, 2.6MB
==> Installing cairo dependency: fontconfig
==> Downloading https://homebrew.bintray.com/bottles/fontconfig-2.13.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring fontconfig-2.13.1.sierra.bottle.tar.gz
==> Regenerating font cache, this may take a while
==> /usr/local/Cellar/fontconfig/2.13.1/bin/fc-cache -frv
?  /usr/local/Cellar/fontconfig/2.13.1: 531 files, 3.3MB
==> Installing cairo dependency: gettext
==> Downloading https://homebrew.bintray.com/bottles/gettext-0.19.8.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gettext-0.19.8.1.sierra.bottle.tar.gz
==> Caveats
gettext is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD gettext library & some software gets confused if both are in the library path.

If you need to have gettext first in your PATH run:
  echo `export PATH="/usr/local/opt/gettext/bin:$PATH"` >> ~/.bash_profile

For compilers to find gettext you may need to set:
  export LDFLAGS="-L/usr/local/opt/gettext/lib"
  export CPPFLAGS="-I/usr/local/opt/gettext/include"

==> Summary
?  /usr/local/Cellar/gettext/0.19.8.1: 1,934 files, 16.9MB
==> Installing cairo dependency: libffi
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.2.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libffi-3.2.1.sierra.bottle.tar.gz
==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/libffi/3.2.1: 16 files, 297.0KB
==> Installing cairo dependency: glib
==> Downloading https://homebrew.bintray.com/bottles/glib-2.58.1.sierra.bottle.tar.gz

curl: (7) Failed to connect to homebrew.bintray.com port 443: Operation timed out
Error: Failed to download resource "glib"
Download failed: https://homebrew.bintray.com/bottles/glib-2.58.1.sierra.bottle.tar.gz
Warning: Bottle installation failed: building from source.
==> Installing dependencies for glib: autoconf, automake, docbook, docbook-xsl, gdbm, readline, sqlite, python@2, libxml2, boost, source-highlight, gtk-doc and libtool
==> Installing glib dependency: autoconf
==> Downloading https://homebrew.bintray.com/bottles/autoconf-2.69.sierra.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring autoconf-2.69.sierra.bottle.4.tar.gz
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> Summary
?  /usr/local/Cellar/autoconf/2.69: 70 files, 3.0MB
==> Installing glib dependency: automake
==> Downloading https://homebrew.bintray.com/bottles/automake-1.16.1_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring automake-1.16.1_1.sierra.bottle.tar.gz
?  /usr/local/Cellar/automake/1.16.1_1: 131 files, 3.4MB
==> Installing glib dependency: docbook
==> Downloading https://homebrew.bintray.com/bottles/docbook-5.0.sierra.bottle.4.tar.gz
######################################################################## 100.0%
==> Pouring docbook-5.0.sierra.bottle.4.tar.gz
==> xmlcatalog --noout --create /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.1.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.1.2/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.3/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.3/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.4/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.4/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.5/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/4.5/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook/5.0/docbook/xml/5.0/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook/5.0/docbook/xml/5.0/catalog.xml /usr/local/etc/xml/catalog
==> Caveats
To use the DocBook package in your XML toolchain,
you need to add the following to your ~/.bashrc:

export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"
==> Summary
?  /usr/local/Cellar/docbook/5.0: 182 files, 4.6MB
==> Installing glib dependency: docbook-xsl
==> Downloading https://homebrew.bintray.com/bottles/docbook-xsl-1.79.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring docbook-xsl-1.79.1.sierra.bottle.tar.gz
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --del file:///usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl-ns/catalog.xml /usr/local/etc/xml/catalog
==> xmlcatalog --noout --add nextCatalog  file:///usr/local/Cellar/docbook-xsl/1.79.1/docbook-xsl-ns/catalog.xml /usr/local/etc/xml/catalog
?  /usr/local/Cellar/docbook-xsl/1.79.1: 3,829 files, 89.5MB
==> Installing glib dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.18.1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.18.1.sierra.bottle.tar.gz
?  /usr/local/Cellar/gdbm/1.18.1: 20 files, 587.0KB
==> Installing glib dependency: readline
==> Downloading https://homebrew.bintray.com/bottles/readline-7.0.5.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring readline-7.0.5.sierra.bottle.tar.gz
==> Caveats
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

==> Summary
?  /usr/local/Cellar/readline/7.0.5: 46 files, 1.5MB
==> Installing glib dependency: sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.26.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring sqlite-3.26.0.sierra.bottle.tar.gz
==> Caveats
sqlite is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:
  echo `export PATH="/usr/local/opt/sqlite/bin:$PATH"` >> ~/.bash_profile

For compilers to find sqlite you may need to set:
  export LDFLAGS="-L/usr/local/opt/sqlite/lib"
  export CPPFLAGS="-I/usr/local/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/sqlite/3.26.0: 11 files, 3.7MB
==> Installing glib dependency: python@2
==> Downloading https://homebrew.bintray.com/bottles/python@2-2.7.15_1.sierra.bottle.7.tar.gz
######################################################################## 100.0%
==> Pouring python@2-2.7.15_1.sierra.bottle.7.tar.gz
==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scri
==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scri
==> /usr/local/Cellar/python@2/2.7.15_1/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scri
==> Caveats
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> Summary
?  /usr/local/Cellar/python@2/2.7.15_1: 4,666 files, 82.5MB
==> Installing glib dependency: libxml2
==> Downloading https://homebrew.bintray.com/bottles/libxml2-2.9.8.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libxml2-2.9.8.sierra.bottle.tar.gz
==> Caveats
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have libxml2 first in your PATH run:
  echo `export PATH="/usr/local/opt/libxml2/bin:$PATH"` >> ~/.bash_profile

For compilers to find libxml2 you may need to set:
  export LDFLAGS="-L/usr/local/opt/libxml2/lib"
  export CPPFLAGS="-I/usr/local/opt/libxml2/include"

For pkg-config to find libxml2 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

==> Summary
?  /usr/local/Cellar/libxml2/2.9.8: 281 files, 10.4MB
==> Installing glib dependency: boost
==> Downloading https://homebrew.bintray.com/bottles/boost-1.68.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring boost-1.68.0.sierra.bottle.tar.gz
?  /usr/local/Cellar/boost/1.68.0: 13,712 files, 451.4MB
==> Installing glib dependency: source-highlight
==> Downloading https://homebrew.bintray.com/bottles/source-highlight-3.1.8_10.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring source-highlight-3.1.8_10.sierra.bottle.tar.gz
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
?  /usr/local/Cellar/source-highlight/3.1.8_10: 422 files, 6MB
==> Installing glib dependency: gtk-doc
==> Downloading https://homebrew.bintray.com/bottles/gtk-doc-1.28.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gtk-doc-1.28.sierra.bottle.tar.gz
?  /usr/local/Cellar/gtk-doc/1.28: 102 files, 2.8MB
==> Installing glib dependency: libtool
==> Downloading https://homebrew.bintray.com/bottles/libtool-2.4.6_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtool-2.4.6_1.sierra.bottle.tar.gz
==> Caveats
In order to prevent conflicts with Apple`s own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.
==> Summary
?  /usr/local/Cellar/libtool/2.4.6_1: 70 files, 3.7MB
==> Downloading https://download.gnome.org/sources/glib/2.58/glib-2.58.1.tar.xz
==> Downloading from https://mirrors.ustc.edu.cn/gnome/sources/glib/2.58/glib-2.58.1.tar.xz
######################################################################## 100.0%
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/59e4d32/glib/hardcoded-paths.diff
######################################################################## 100.0%
==> Downloading https://raw.githubusercontent.com/Homebrew/formula-patches/5857984/glib/revert-appinfo-contenttype.patch
######################################################################## 100.0%
==> Patching
==> Applying hardcoded-paths.diff
patching file gio/gdbusprivate.c
Hunk #1 succeeded at 2098 (offset -1 lines).
Hunk #2 succeeded at 2108 (offset -1 lines).
patching file gio/xdgmime/xdgmime.c
patching file glib/gutils.c
Hunk #1 succeeded at 2043 with fuzz 2 (offset 105 lines).
==> Applying revert-appinfo-contenttype.patch
patching file gio/Makefile.am
Hunk #2 succeeded at 405 (offset 11 lines).
Hunk #3 succeeded at 640 (offset 35 lines).
Hunk #4 succeeded at 923 (offset 37 lines).
Hunk #5 succeeded at 933 (offset 37 lines).
patching file gio/giomodule.c
Hunk #2 succeeded at 1024 (offset 16 lines).
Hunk #3 succeeded at 1165 (offset 16 lines).
patching file gio/glocalfileinfo.c
Hunk #1 succeeded at 1308 (offset 18 lines).
patching file gio/tests/Makefile.am
Hunk #1 succeeded at 353 (offset 6 lines).
==> ./autogen.sh
==> ./configure --disable-maintainer-mode --disable-silent-rules --disable-dtrace --disable-libelf --enable-static --prefix=/usr/local/Cellar/glib/2.58.1 --localstatedir=/usr/l
==> make
==> make install
?  /usr/local/Cellar/glib/2.58.1: 451 files, 18.8MB, built in 2 minutes 52 seconds
==> Installing cairo dependency: pixman
==> Downloading https://homebrew.bintray.com/bottles/pixman-0.34.0_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring pixman-0.34.0_1.sierra.bottle.tar.gz
?  /usr/local/Cellar/pixman/0.34.0_1: 13 files, 1.3MB
==> Installing cairo
==> Downloading https://homebrew.bintray.com/bottles/cairo-1.16.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cairo-1.16.0.sierra.bottle.tar.gz
?  /usr/local/Cellar/cairo/1.16.0: 117 files, 5.5MB
==> Caveats
==> gettext
gettext is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD gettext library & some software gets confused if both are in the library path.

If you need to have gettext first in your PATH run:
  echo `export PATH="/usr/local/opt/gettext/bin:$PATH"` >> ~/.bash_profile

For compilers to find gettext you may need to set:
  export LDFLAGS="-L/usr/local/opt/gettext/lib"
  export CPPFLAGS="-I/usr/local/opt/gettext/include"

==> libffi
libffi is keg-only, which means it was not symlinked into /usr/local,
because some formulae require a newer version of libffi.

For compilers to find libffi you may need to set:
  export LDFLAGS="-L/usr/local/opt/libffi/lib"

For pkg-config to find libffi you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"

==> autoconf
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/autoconf
==> docbook
To use the DocBook package in your XML toolchain,
you need to add the following to your ~/.bashrc:

export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"
==> readline
readline is keg-only, which means it was not symlinked into /usr/local,
because macOS provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

For compilers to find readline you may need to set:
  export LDFLAGS="-L/usr/local/opt/readline/lib"
  export CPPFLAGS="-I/usr/local/opt/readline/include"

==> sqlite
sqlite is keg-only, which means it was not symlinked into /usr/local,
because macOS provides an older sqlite3.

If you need to have sqlite first in your PATH run:
  echo `export PATH="/usr/local/opt/sqlite/bin:$PATH"` >> ~/.bash_profile

For compilers to find sqlite you may need to set:
  export LDFLAGS="-L/usr/local/opt/sqlite/lib"
  export CPPFLAGS="-I/usr/local/opt/sqlite/include"

For pkg-config to find sqlite you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> python@2
Pip and setuptools have been installed. To update them
  pip install --upgrade pip setuptools

You can install Python packages with
  pip install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python
==> libxml2
libxml2 is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have libxml2 first in your PATH run:
  echo `export PATH="/usr/local/opt/libxml2/bin:$PATH"` >> ~/.bash_profile

For compilers to find libxml2 you may need to set:
  export LDFLAGS="-L/usr/local/opt/libxml2/lib"
  export CPPFLAGS="-I/usr/local/opt/libxml2/include"

For pkg-config to find libxml2 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"

==> source-highlight
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> libtool
In order to prevent conflicts with Apple`s own libtool we have prepended a "g"
so, you have instead: glibtool and glibtoolize.

複製程式碼

再次安裝canvas,成功了。

注意

值得注意的是:我這裡並沒有按照npm install canvas簡明指南所說的去安裝XQuartz,因為在這之前我通過brew安裝了pkg-config。

相關文章