无法在 Mac OS 上安装 fabric.js

Not able to install fabric.js on Mac OS

我无法在 mac os 上安装 fabric js。目前从事离子项目。下面是我的项目配置

1.离子-v3

2。 Angular - v6

3。科尔多瓦

我在终端运行下面的命令

npm i fabric

但是我遇到了以下错误

Mobiles-MacBook-Pro:lib mobilesolution$ npm i fabric

> canvas@1.6.11 install /usr/local/lib/node_modules/fabric/node_modules/canvas
> node-gyp rebuild

./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:160:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/node/9.4.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/fabric/node_modules/canvas
gyp ERR! node -v v9.4.0
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.11 (node_modules/fabric/node_modules/canvas):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.11 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ fabric@2.3.3
added 82 packages from 192 contributors in 4.071s

我尝试了很多解决方案,但没有任何效果。即使我试图更新 os 版本。尽管我发现相同的 issue.I 尝试了以下命令

cd /usr/local/lib sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib

sudo apt-get install build-essential
received error as apt-get not defined

apt-get remove gyp

xcode-select --install

sudo xcode-select --switch

node-gyp configure

sudo xcode-select -s /Library/Developer/CommandLineTools

softwareupdate --install -a

我得到了解决方案。我忘了安装cairo..

我关注了thislink得到了答案。现在它工作正常。能够安装fabric.js

我运行下面的命令..

brew install cairo
brew install pkg-config