简体   繁体   English

Node.js 在 mac osx 10.8.4 上安装画布失败:src/Canvas.h……致命错误:找不到 v8.h 文件

[英]Node.js install canvas failed on mac osx 10.8.4 : src/Canvas.h…fatal error: v8.h file not found

I install nodejs following nodejs wiki, it's going well, and then install node canvas following this way https://github.com/LearnBoost/node-canvas/wiki/Installation---OSX , the steps before "$ npm install canvas" were going well, but the final step "$ npm install canvas" was failed again and again, I have tried install the Nodejs both building and installing, and i also try "sudo", and I have try "$ export PKG_CONFIG_PATH=.....", but still can't install canvas, I'm sure I have followed all the guide clarely.我按照nodejs wiki安装nodejs,一切顺利,然后按照这种方式安装node canvas https://github.com/LearnBoost/node-canvas/wiki/Installation---OSX,“$ npm install canvas”之前的步骤进展顺利,但最后一步“$ npm install canvas”一次又一次失败,我尝试安装Nodejs,包括构建和安装,我也尝试过“sudo”,我尝试过“$ export PKG_CONFIG_PATH=.. ...”,但仍然无法安装画布,我确定我已经清楚地遵循了所有指南。 Below is the log:下面是日志:

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

To fix it:要解决这个问题:

  1. Download the source code of node 0.10.13 from http://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gzhttp://nodejs.org/dist/v0.10.13/node-v0.10.13.tar.gz下载节点 0.10.13 的源代码
  2. Extract this file via tar -xvz node-v0.10.13.tar.gz通过 tar -xvz node-v0.10.13.tar.gz 解压此文件
  3. Copy the 'deps', 'src' and 'tools' folders into '~/.node-gyp/0.10.13'将“deps”、“src”和“tools”文件夹复制到“~/.node-gyp/0.10.13”

Then run 'npm install canvas' again.然后再次运行“npm install canvas”。

I have no idea why the MacOS node package(just for v0.10.13) is missing these things.我不知道为什么 MacOS 节点包(仅适用于 v0.10.13)缺少这些东西。

I just ran into this problem myself.我自己刚刚遇到了这个问题。 You may need to install some dependencies.您可能需要安装一些依赖项。 Try running the following command in terminal.尝试在终端中运行以下命令。

brew install pkg-config cairo pango libpng jpeg giflib librsvg

Afterwards, rerun npm install.之后,重新运行 npm install。 This worked for me.这对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 致命错误:在 mac osx 10.10.5 下找不到“common.h”文件 - fatal error: 'common.h' file not found under mac osx 10.10.5 OSX 10.7.5:致命错误:找不到'ft2build.h'文件 - OSX 10.7.5: fatal error: 'ft2build.h' file not found pecl在Mac上安装mongodb,致命错误:找不到“ Security / Security.h”文件 - pecl install mongodb on mac, fatal error: 'Security/Security.h' file not found 在Mac上安装Caffe错误:“致命错误:找不到&#39;cblas.h&#39;文件” - Install Caffe on Mac error: “fatal error: 'cblas.h' file not found” 致命错误:在Mac上找不到“ ext / hash_map.h”文件 - fatal error: 'ext/hash_map.h' file not found on Mac 试图在 Mac OS Catalina 上安装 GNUPlot……../term/lua.trm:107:10:致命错误:找不到“lua.h”文件 - Trying to install GNUPlot on Mac OS Catalina… ../term/lua.trm:107:10: fatal error: 'lua.h' file not found pip 安装 uwsgi 失败,出现 /usr/local/include/string/string.h:7:10:致命错误:找不到“流”文件? - pip install uwsgi failed with /usr/local/include/string/string.h:7:10: fatal error: 'sstream' file not found? 严重错误:找不到&#39;omp.h&#39;文件 - fatal error: 'omp.h' file not found 如何修复 OSX 中的“致命错误:&#39;sys/epoll.h&#39; 文件未找到”? - How to fix “fatal error: 'sys/epoll.h' file not found” in OSX? 致命错误:找不到&#39;endian.h&#39;文件 - fatal error: 'endian.h' file not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM