There’s an article here that describes the process, but it’s a bit vague in some areas and didn’t work for me.
If you’re on 64-bit Windows, you will need the 64-bit version of GTK which comes bundled with Cairo if you get the all-in-one package. Somewhere under the mile of text on this page you should find a link to it; here’s a direct link for version 2.22.
It’s a zip. Extract it to c:/GTK. I don’t even what to consider what’s involved making it work from a different location.
You also need node-gyp. Install it via
Once you’ve got all the dependencies you can attempt to install node-canvas. “CD” into your project directory and then run
Adjust the version number for whatever version of Visual Studio you have. The Wiki says to use VC++ 2010 Express which is also a bitch to find on Microsoft’s website as they push you towards 2013. Here’s a direct link which may or not work.
Even after installing VS2010 though, npm/gyp wouldn’t pick it up automatically, which is why I had to specify the version manually. Even then 2010 didn’t work, but 2012 did, so, whatever.
If you get some linker errors, you probably have an old version of Cairo.
If you get something about cairo-features, it’s probably the same deal. Those can be fixed by opening the .sln in Visual Studio and updating the include dirs to include C:/GTK/includes/cairo, but then you’ll be left with a new error, and they’ll probably never end, so just try different versions of the GTK bundle until you find one that works. Maybe try 32-bit if the 64-bit one doesn’t work for you (32 didn’t work for me).
3 thoughts on “Installing node-canvas on Windows”
when you say “CD” into your project directory and then run : npm install canvas –msvs_version=2012
I am not sure what “project directory” you are referring to. I don’t have any project, I need to install this node-canvas as a dependency for
A dependency for what? You should run “npm install” in the same directory that “package.json” and “node_modules” are in.
If librsvg is available when node-canvas is installed, node-canvas can render SVG images to your canvas context. This currently works by rasterizing the SVG image (i.e. drawing an SVG image to an SVG canvas will c not preserve the SVG data).