Installation Windows

Zach Bjornson edited this page Nov 22, 2016 · 25 revisions

Dependencies

Building the node-canvas module requires:

  1. A global installation of node-gyp, which requires:
    • Python 2.7 for Windows
    • Microsoft Visual C++ 2010 or later
  2. GTK 2
  3. For optional JPEG support (pending #841): libjpeg-turbo

1. Installing node-gyp

  • Run the latest 2.7.x Python installer (v3.x.x is not supported).
  • Install Visual Studio. Community and Express are both free. Community is a bigger installation but provides more features; Express is sufficient. When installing, ensure that you select the option for C++ support. You can also try the C++ Build Tools as described here.
  • Install node-gyp globally with npm install -g node-gyp.

Notes:

  • We've tested Visual Studio 2010, 2013 and 2015, x86 and x64.
  • Ensure the Python directory (e.g C:\Program Files\Python) is available in PATH.
  • You can force gyp to use a specific edition of VS, by providing a --msvs_version=2013 hint to npm install canvas (if you're installing from scratch) or node-gyp rebuild (if you're building node-canvas).
  • If anything goes wrong, please refer to the node-gyp documentation.

2. Installing GTK 2

You will need the cairo library which is bundled in GTK. Download the GTK 2 bundle for Win32 or Win64. Unzip the contents in C:\GTK.

Notes:

  • Both GTK and Node.js need either be 64bit or 32bit to compile successfully.
  • Download GTK 2, not GTK 3, which is missing the required libpng. If you get linker errors you've most likely picked the wrong bundle.
  • If you use a different location than C:\GTK, add a GTK_Root argument to npm install or node-gyp rebuild. For example: node-gyp rebuild --GTK_Root=C:\somewhere\GTK.

3. Installing libjpeg-turbo

Download the latest libjpeg-turbo SDK for Visual C++ (currently libjpeg-turbo-1.5.1-vc.exe or libjpeg-turbo-1.5.1-vc64.exe) and install to its default location (C:\libjpeg-turbo if 32bit or C:\libjpeg-turbo64 if 64bit).

Notes:

  • Both libjpeg-turbo and Node.js need either be 64bit or 32bit to compile successfully.
  • If you use a different location, add a jpeg_root argument to npm install or node-gyp rebuild. For example: node-gyp rebuild --jpeg_root=C:\somewhere\libjpeg-turbo.

Build instructions

In the root of the node-canvas module you may use node-gyp to build the native module:

node-gyp rebuild