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

孤街浪徒 提交于 2020-01-12 04:54:28

问题


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.


回答1:


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




回答2:


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




回答3:


Node itself and other "close to core" libraries, like node-gyp, 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.




回答4:


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

Just run as administrator:

npm install --global --production windows-build-tools

And wait for the installation to complete.

Contents

  • Visual C++ Compilers (targeting x86, X64 and ARM)
  • Visual C++ headers & libraries (CRT & STL)
  • Visual C++ build scripts (targeting Windows desktop)
  • Microsoft Build Tools 2015 (MSBuild)
  • Windows SDK 8.1 (optional, on by default)
  • Windows SDK 10 (optional, off by default)
  • ATL and MFC (optional, off by default)
  • C++ Build tools specific command prompts


来源:https://stackoverflow.com/questions/26959640/why-does-node-gyp-and-other-stuff-require-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!