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

2020-05-26 04:45发布

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条回答
做个烂人
2楼-- · 2020-05-26 04:48

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.

查看更多
贪生不怕死
3楼-- · 2020-05-26 04:51

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

查看更多
beautiful°
4楼-- · 2020-05-26 04:53

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

查看更多
Root(大扎)
5楼-- · 2020-05-26 04:56

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.

查看更多
登录 后发表回答