无法安装npm包canvas

时间:2015-07-26 21:17:27

标签: node.js canvas npm

我一直在尝试整天安装npm包canvas。我跑了:

sudo npm install canvas

但我明白了:

canvas@1.2.4 install /home/mark/Programming/canvas_npm/node_modules/canvas

node-gyp rebuild
make: Entering directory /home/mark/Programming/canvas_npm/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:7:0: ../src/Canvas.h:22:17: fatal error: nan.h: No such file or directory #include <nan.h> ^ compilation terminated. make: *** [Release/obj.target/canvas/src/Canvas.o] Error 1 make: Leaving directory/home/mark/Programming/canvas_npm/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/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Linux 3.13.0-37-generic
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/mark/Programming/canvas_npm/node_modules/canvas
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok 
npm ERR! Linux 3.13.0-37-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "canvas"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE

npm ERR! canvas@1.2.4 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@1.2.4 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls canvas
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/mark/Programming/canvas_npm/npm-debug.log

导致错误的具体问题似乎是:

fatal error: nan.h: No such file or directory

我已经使用自制软件安装了Cairo。我想为什么我不能安装画布?

2 个答案:

答案 0 :(得分:1)

我的解决方案(对于Ubuntu)是安装nan包:

npm install nan

然后将nan标头复制到/usr/include/

sudo cp node_modules/nan/nan*.h /usr/include/

答案 1 :(得分:0)

看起来它是canvas 1.2.24版的一个问题。我通过安装1.2.23

解决了