Centos 7节点canvas/Fabricjs编译错误

Centos 7 node canvas/Fabricjs compile error

在 AWS Centos 7 机器上,我正在努力安装 Fabricjs 并在 Angular 4 网络应用程序中工作。 运行系统库问题超出了我对Centos 7的理解。我该如何解决?

npm install fabric --save

> canvas@1.6.6 install /data/ng-app/node_modules/canvas
> node-gyp rebuild

make: Entering directory `/data/ng-app/node_modules/canvas/build'
  SOLINK_MODULE(target) Release/obj.target/canvas-postbuild.node
  COPY Release/canvas-postbuild.node
  CXX(target) Release/obj.target/canvas/src/Canvas.o
In file included from ../src/Canvas.cc:20:0:
../src/JPEGStream.h:10:21: fatal error: jpeglib.h: No such file or directory
 #include <jpeglib.h>
                     ^
compilation terminated.
make: *** [Release/obj.target/canvas/src/Canvas.o] Error 1
make: Leaving directory `/data/ng-app/node_modules/canvas/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules.bundled/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 3.10.0-327.36.1.el7.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /data/ng-app/node_modules/canvas
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
ng-app@0.0.0 /data/ng-app
├── UNMET PEER DEPENDENCY @angular/common@4.4.0-RC.0
├── UNMET PEER DEPENDENCY @angular/compiler@4.4.0-RC.0
├── UNMET PEER DEPENDENCY @angular/core@4.4.0-RC.0
└── fabric@2.0.0-beta.6

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN angular4-drag-drop@1.0.1 requires a peer of @angular/core@>=4.0.0 <5.0.0 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN angular4-drag-drop@1.0.1 requires a peer of @angular/common@^4.0.0 but none was installed.
npm WARN codelyzer@3.1.2 requires a peer of @angular/compiler@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN codelyzer@3.1.2 requires a peer of @angular/core@^2.3.1 || >=4.0.0-beta <5.0.0 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.6 (node_modules/canvas):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: canvas@1.6.6 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
[test1@ip-172-31-55-23 ng-app]$ exit
logout

对于它的价值,我似乎安装了引用的库,但不能确定:

# yum install libjpeg
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirror.constant.com
 * epel: s3-mirror-us-east-1.fedoraproject.org
 * extras: mirror.lug.udel.edu
 * updates: mirror.trouble-free.net
Package libjpeg-turbo-1.2.90-5.el7.x86_64 already installed and latest version
Nothing to do

您需要安装这些库的开发版本。 node-canvas 建议的是:

sudo yum install cairo cairo-devel cairomm-devel libjpeg-turbo-devel pango pango-devel pangomm pangomm-devel giflib-devel

如果您打算在浏览器中 angular 使用 fabricjs,您不需要从 npm 安装它,您仍然可以从 CDN 引用它,这对您来说更容易,并且可能会减少部署时间。