Tuesday, January 13, 2015

Installing node-canvas on Win64 and Visual Studio 2013 Update 4


While exploring machine learning using JavaScript I came across this nice video and github project by Heather Arthur.

I decided to try it out, but I had to resolve quite a few issues. Here is the takeaway from the solution:

  • Install 32bit version of python instead of 64bit.

    • This is help overcome a lot of issues later when installing python libraries as the library installer look for details in registry to check if specific version of Python is installed or not. And with 64bit installation it wasn’t able to detect it.

  • node-canvas requires cairo which can be installed on Windows via the GTK+ package.

    • Download the 64 bit 2.22 all-in-one bundle for 64bit machines or else the C++ compiler will throw LINKER errors while building the package.
    • Make sure to follow the instructions in the gtk+-bundle_2.22.1-20101229_win64.README.txt file at the root of the bundle
    • Copy all the contents of the bundle to “C:\GTK” folder as the node-gyp needs that

  • Use the –-msvs_version=2013 switch to install the ‘canvas’ package

    • I got this error while installing the ‘canvas’ npm package from Visual Studio
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets(64,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Upgrade Solution...".
    • I had to do 2 things to resolve it:
      • Update node-gyp to the latest version, including the one that is internally used by node
      • Use ‘npm install –-msvs_version=2013 canvas’ from command line to install the package.

Finally add the canvas package with version number in dependencies in package.json to make Visual studio happy…


Scallopboat said...

Thank you! This was kicking my ass for a while.

Unknown said...

Thank you!