我在github下载了node-canvas模块的代码,运行了自带的例子clock.js,结果: module.js:340 throw err; ^ Error: Cannot find module ‘…/build/Release/canvas’ at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.<anonymous> (/home/fdd/node_modules/node-canvas/lib/bindings.js:2:18) at Module._compile (module.js:456:26) at Object.Module._extensions…js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17)
为什么会有错误?官网的东西,不应该有错啊?
代码是我通过git clone方式获取的,运行前需不需要进行npm install安装啊?
@yihuaxiang Node canvas is a Cairo backed Canvas implementation for NodeJS 应该需要安装Cairo http://cairographics.org/
@jiangli373 安装了的,
18:38 fdd@fdd:~ $sudo apt-get install libcairo2-dev
[sudo] password for fdd:
正在读取软件包列表… 完成
正在分析软件包的依赖关系树
正在读取状态信息… 完成
libcairo2-dev 已经是最新的版本了。
@bnuhero 前面都正常,但是到了sudo npm install canvas 时:
19:01 fdd@fdd:~ $sudo npm install canvas
[email protected] install /home/fdd/node_modules/canvas node-gyp rebuild
gyp ERR! UNCAUGHT EXCEPTION
gyp ERR! stack Error: EPERM, utime ‘/home/fdd/.node-gyp/0.10.30’
gyp ERR! System Linux 3.13.0-33-generic
gyp ERR! command “node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /home/fdd/node_modules/canvas
gyp ERR! node -v v0.10.30
gyp ERR! node-gyp -v v0.13.1
gyp ERR! This is a bug in node-gyp
.
gyp ERR! Try to update node-gyp and file an Issue if it does not help:
gyp ERR! https://github.com/TooTallNate/node-gyp/issues
npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the [email protected] 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 Linux 3.13.0-33-generic npm ERR! command “/usr/local/bin/node” “/usr/local/bin/npm” “install” “canvas” npm ERR! cwd /home/fdd npm ERR! node -v v0.10.30 npm ERR! npm -v 1.4.21 npm ERR! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /home/fdd/npm-debug.log npm ERR! not ok code 0