Fixing failing npm packages on Windows (i.e. microtime, forever)

I got into fun side project in node.js, and being Windows kid, I wanted to run it on my Windows dev machine. The thing is, it’s not that easy. Well, you can install node easily, and there is some tooling available too. The biggest PITA is that some packages are hard to build on Windows. And when you go through issues at GitHub, popular response seems to be “I don’t have any Windows box to test it and make it work” ;)

It took me several hours, but I managed to fix all the issues I had yesterday, so here’s my answer to some popular errors:

Error: Can’t find Python executable “python”

Npm (node package manager) uses build system called gyp, that runs some python scripts. It would be hard to find linux machine without python, but Windows folks often don’t have it, because they don’t need it. Me including. So install python first! They say 2.7 is good choice for gyp. And after that, add PYTHON env variable that points to your python catalog. Actually, it should point to your python.exe, because you’ll get another error I don’t remember right now (something about ENOENT).

MSBUILD : error MSB3428: Could not load the Visual C++ component “VCBuild.exe”

From what I read around Internets, this error affects Visual Studio 2013 users. It happens, because when you install node.js it has built-in node-gyp package. When you npm install node-gyp, this built-in instance is not updated, so you don’t have latest version. And sometimes it’s good to get latest version, i.e. to get VS 2013 support. This instruction helped me to update built-in node-gyp.

A little bit about tooling

I’m new to node.js and currently cannot decide what’s my favourite tooling. I’m switching between IntelliJ IDEA plugin, Node Tools for Visual Studio or running it manually from Powershell. All of them have their ups and downs. I like IntelliJ plugin, because it is stable and plays nicely. Node Tools for VS seems to have much potential, and integrate neatly with VS look and feel, but are *very* unstable (they’re still in alpha). One example – running project, where you lack some of the dependencies cause whole VS to crash. If you want to try them anyway, Scott Hanselman wrote nice introduction post.

Anyway, after fixing those build errors, node.js seems like something fun to learn. I may be covering this topic more in the future.