Node.js安装canvas在Mac OS X 10.8.4上失败:src / Canvas.h …致命错误:找不到v8.h文件

我在nodejs wiki之后安装了nodejs,这很顺利,然后按照这种方法安装node canvas, https://github.com/LearnBoost/node-canvas/wiki/Installation–OSX ,“$ npm install canvas”进展顺利,但最后一步“$ npm安装canvas”失败了一次又一次,我已经尝试安装Nodejs都build设和安装,我也尝试“sudo”,我已经尝试“$出口PKG_CONFIG_PATH = .. …“,但仍然不能安装canvas,我确信我已经遵循了所有的指导。 以下是日志:

SLMacs-MacBook-Pro-2:~ percy$ npm install canvas npm http GET https://registry.npmjs.org/canvas npm http 304 https://registry.npmjs.org/canvas > canvas@1.0.3 install /Users/macbookpro/node_modules/canvas > node-gyp rebuild CXX(target) Release/obj.target/canvas/src/Canvas.o In file included from ../src/Canvas.cc:7: ../src/Canvas.h:11:10: fatal error: 'v8.h' file not found #include <v8.h> ^ 1 error generated. make: *** [Release/obj.target/canvas/src/Canvas.o] Error 1 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/node-gyp/lib/build.js:267:23) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:96:17) gyp ERR! stack at Process._handle.onexit (child_process.js:678:10) gyp ERR! System Darwin 12.4.0 gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild" gyp ERR! cwd /Users/macbookpro/node_modules/canvas gyp ERR! node -v v0.8.12 gyp ERR! node-gyp -v v0.10.6 gyp ERR! not ok npm ERR! canvas@1.0.3 install: `node-gyp rebuild` npm ERR! `sh "-c" "node-gyp rebuild"` failed with 1 npm ERR! npm ERR! Failed at the canvas@1.0.3 install script. 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! System Darwin 12.4.0 npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "canvas" npm ERR! cwd /Users/macbookpro npm ERR! node -v v0.8.12 npm ERR! npm -v 1.1.63 npm ERR! code ELIFECYCLE npm ERR! Error: EACCES, open 'npm-debug.log' npm ERR! { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path: 'npm-debug.log' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.4.0 npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "canvas" npm ERR! cwd /Users/macbookpro npm ERR! node -v v0.8.12 npm ERR! npm -v 1.1.63 npm ERR! path npm-debug.log npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, open 'npm-debug.log' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/macbookpro/npm-debug.log npm ERR! not ok code 0 

要解决这个问题:

  1. http://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gz下载节点0.10.13的源代&#x7801;
  2. 通过tar -xvz node-v0.10.13.tar.gz解压缩此文件
  3. 将“deps”,“src”和“tools”文件夹复制到“〜/ .node-gyp / 0.10.13”

然后再次运行“npm install canvas”。

我不知道为什么MacOS节点包(只适用于v0.10.13)缺less这些东西。