Centos 7节点canvas / fabricjs编译错误

时间:2017-09-07 18:02:01

标签: fabricjs centos7 libjpeg

在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

1 个答案:

答案 0 :(得分:2)

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

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

如果您打算在浏览器中以角度使用fabricjs,则无需从npm安装它,您仍然可以从CDN引用它,对您来说更方便,并且可能会缩短部署时间。