Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Error installing canvas with npm #137

e98cuenc opened this Issue · 16 comments

9 participants


I tried to install canvas in a Mac Snow Leopard with latest node (0.6.6):

cuenca-macbookair:~ cuenca$ npm install canvas
npm info it worked if it ends with ok
npm info using npm@1.1.0-beta-4
npm info using node@v0.6.6
npm http GET
npm http 304
npm info into /Users/cuenca canvas@0.8.2
npm info installOne canvas@0.8.2
npm info unbuild /Users/cuenca/node_modules/canvas
npm info preinstall canvas@0.8.2

canvas@0.8.2 preinstall /Users/cuenca/node_modules/canvas
node-waf configure build

Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok

Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for library gif : not found
Checking for library jpeg : yes
Checking for cairo : yes
'configure' finished successfully (0.706s)
Waf: Entering directory /Users/cuenca/node_modules/canvas/build'
[1/9] cxx: src/ -> build/Release/src/Canvas_1.o
[2/9] cxx: src/ -> build/Release/src/CanvasGradient_1.o
[3/9] cxx: src/ -> build/Release/src/CanvasRenderingContext2d_1.o
[4/9] cxx: src/ -> build/Release/src/color_1.o
[5/9] cxx: src/ -> build/Release/src/Image_1.o
[6/9] cxx: src/ -> build/Release/src/ImageData_1.o
[7/9] cxx: src/ -> build/Release/src/init_1.o
[8/9] cxx: src/ -> build/Release/src/PixelArray_1.o
[9/9] cxx_link: build/Release/src/Canvas_1.o build/Release/src/CanvasGradient_1.o build/Release/src/CanvasRenderingContext2d_1.o build/Release/src/color_1.o build/Release/src/Image_1.o build/Release/src/ImageData_1.o build/Release/src/init_1.o build/Release/src/PixelArray_1.o -> build/Release/canvas.node
ld: warning: directory '/lib' following -L not found
Waf: Leaving directory
'build' finished successfully (4.705s)
npm info build /Users/cuenca/node_modules/canvas
npm info linkStuff canvas@0.8.2
npm info install canvas@0.8.2
npm info postinstall canvas@0.8.2
canvas@0.8.2 ./node_modules/canvas
npm info ok
cuenca-macbookair:~ cuenca$ node

Error: Cannot find module '../build/default/canvas'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object. (/Users/cuenca/node_modules/canvas/lib/bindings.js:7:20)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Module.require (module.js:357:17)

Any ideas on what went wrong?



I had the same problem. I did "sudo port upgrade cairo" (takes a looong time), then "npm remove canvas" and finally "npm install canvas" again. It now works fine for me.


I'm using cairo from brew and cairo is updated with the last version available. The issue seems to be the config script is trying to link with -L /lib, and /lib doesn't exist in the mac. No idea what's wrong, it maybe a problem in cairo, but it looks like a problem in node-canvas configure script.

tj commented

hm i dont have this issue on lion or snow leopard, but I didn't install with brew


yup, compiling it from source fixes it obviously


I just ran into this issue after upgrading to node 0.6.11 (from 0.6.10). Upgrading again to 0.6.12 caused the issue to go away. No idea if the version numbers are significant here, or if upgrading was triggering something else, or if it was complete coincidence.


I am having the same issue, any solution?


I resolved this downgrading to node v0.4


Don't downgrade to 0.4, this is not the way to do it. Just compile it from source.


Where can I compile from source? And am I compiling canvas or cario? All of this is so frustrating. All I want to do is have a simple stylus css pre-processor running with nib support, and canvas NEVER EVER works right on any of the npm installs. can't someone just share their OS X binary? The entire nature of these easier to use installs means I was weeks of my time trying to get something to work when somebody else could just send me the binary they built.


@ckizer I only have some older version here... OSX Lion, but canvas 0.11.2:

tj commented

@ckizer you should be able to just plunk it in your ./node_modules, or anywhere in the NODE_PATH. require('canvas') checks .node


Here's a 0.12.0 build (also OS X Lion):


For problems with node 0.8 that are not solved by adding --use-clang or --universal:



try to run $ sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev
It will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.