Why does node-gyp (and other stuff) require Visual Studio?

14.8k Views Asked by At

node-gyp isn't the first thing I've run into requiring it, but this seems odd. I assume this has something to do with building executables or plugins or whatever but is there no dependency smaller than a complete version of Visual Studio or VS Express that can fit the bill? I though you could actually write, build and run .net apps without a copy of VS if you really wanted to. I ask with intent to at least learn some C++ or whatever else it takes while attempting to address the problem although I imagine it's nontrivial if Joyent couldn't find a way around it easily enough.

Note: I'm not having a problem with node-gyp as a node dependency but Windows users with that issue should try updating node by downloading from the web and reinstalling from that exe file before doing any of the other madness out there that I narrowly dodged. They seem to have fixed the 2010-only issue without really announcing it very loudly and npm doesn't really work when attempting to update itself and Node on Windows.

4

There are 4 best solutions below

1
On BEST ANSWER

It works without Visual Studio, but you'll need to install Windows SDK:

  1. Get Windows SDK from https://www.microsoft.com/en-us/download/details.aspx?id=8442
  2. Use "SDK command line" shortcut on your desktop to launch npm install

I found this solution here: https://github.com/nodejs/node-gyp/issues/629#issuecomment-138276692

1
On

Node itself and other "close to core" libraries, like node-gyp, require a C++ compiler. In most dev environments on Windows this will be Visual Studio in combination with Python. However you could also use MinGW or Cygwin with gcc installed.

The experience of doing stuff with gcc directly would compare to compiling .NET code on the Windows platform. However gcc doesn't feel native on Windows.

2
On

Update: You can download latest build tools here. Recent announcements here and here.

Original answer: Finally Microsoft is providing much better solution. A standalone Microsoft Visual C++ Build Tools 2015 Technical Preview. More info here and here

1
On

EDIT:

Please note that the official Node.js for Windows installer can now automatically install the required tools. That's likely a much better option than the module listed here (windows-build-tools).


ORIGINAL ANSWER:

I was able to run node-gyp 0.8.x on Windows 10 without Visual Studio using the windows-build-tools.

Install the build tools with this one-liner. Start PowerShell as Administrator and run:

npm install --global windows-build-tools

And wait for the installation to complete.