我在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安装啊?
需要 npm install
@jiangli373 我进行了npm install之后还是有那个错误。
node-canvas 下有个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
canvas@1.1.6 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! canvas@1.1.6 install: node-gyp rebuild
npm ERR! Exit status 7
npm ERR!
npm ERR! Failed at the canvas@1.1.6 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
其实我个人觉得node-canvas是比较难装的包,依赖各种各种
@yaochun 那有什么好用的类似canvas处理照片的包不?
$ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
的安装正常吗?另外你用的什么版本的Ubuntu和Python?
我在Ubuntu 14.04下安装,没遇到问题。
@yihuaxiang http://cnodejs.org/topic/53dc8ff8111cfedf0bbd9c8c
我自己项目用过的qr-image,没有依赖,支持utf-8推荐给你