node-gyp icon indicating copy to clipboard operation
node-gyp copied to clipboard

Windows users are not happy.

Open luisrudge opened this issue 11 years ago • 474 comments

It all started with this conversation.

As I said, I'm pretty much a newbie and I don't even know what node-gyp does, but what I DO know is that it's a pain to run Windows and install a project with node-gyp as a dependency. Some numbers:

It's bizarre that a nodejs developer needs to install visual studio (even the express edition) in order to be able to work on Windows. Even more bizarre is that I, as a .NET developer with full visual studio installed in my machine still can't download a bunch of projects that use this project.

With that being said, I'd like to know from all of you what should we do to make windows users fall in the pit of success? What are the alternatives? Does Microsoft can solve this in any way?

This issue is fixed (kinda)

@mousetraps pointed that Microsoft is shipping the C++ build tools separately now. Check here

Some updates on this gigantic thread

Absolutely non-official statement that @Microsoft is aware of this issue and seeing what can be done

@mousetraps said that this thread "is high on people's radar" at @Microsoft

Very good Q&A about noge-gyp issues on Windows and why they happen

@dekarguy took the time to answer some questions about what we all are going through

luisrudge avatar May 22 '15 03:05 luisrudge

Not only does it require Python, it requires Python 2. But, I mean, Python 3 has only been out for seven years. I guess it's too soon to expect that to be supported. :\

Pharylon avatar Sep 29 '15 18:09 Pharylon

https://code.google.com/p/gyp/issues/detail?id=36&q=python%203

Until gyp itself has Python 3 support, node-gyp is stuck with the Python 2 requirement

dekarguy avatar Sep 29 '15 18:09 dekarguy

Hey everyone, just a quick update on things from the Microsoft end of things. This thread has made its rounds amongst the product teams, and is high on people's radar. I also spoke with the C++ team, and they want to help, but we're still investigating, so we can't make any promises just yet.

There are two key issues at play here:

  1. It's not entirely clear which specific components are required: Currently we're trying to figure out a set of minimal dependencies required - what headers, libraries, versions, targets files, etc. It would also be helpful to get a set of npm packages that should work so we can ensure we don't miss anything. If anyone has deeper context on this, then lmk - it would be great to run things by you. (@orangemocha let's sync up since it seems you're also diving into this?)
  2. We need a way to bundle these components into a single install: That may take more or less time depending on what teams need to be involved (see _#_1), but as alluded to above - just about everyone I've connected with here agrees that downloading full VS is not a reasonable expectation, and wants to do something about the problem. There may also be some good biz justification from Azure because it would make their provisioning process easier.

Anyways... I know it still feels like all talk right now, but hopefully things'll get more concrete as we continue to investigate. :smiley:

mousetraps avatar Sep 29 '15 21:09 mousetraps

Thank you @mousetraps! Really. It's great to know that this is being talked internally at MS. Please keep us posted!

luisrudge avatar Sep 29 '15 21:09 luisrudge

@mousetraps,

Binary compatibility is a key challenge on all platforms for any node.js package with native module. For instance, to have binary working on "most" of the Linux distributions, we build on old CentOS 5. For FreeBSD, the one built on v10, does not work on FreeBSD 8. Same the case with OSX. On Windows XP-10 compatible binary can be built on 10 with VS2015, which is great deal IMVHO.

Binary distribution is another challenge: as there is no uniform way of distributing binaries. Some packages are distributing via GitHub repos and some are using cloud services (S3 buckets), but both kinds are providing a fallback option to build from source during the installation. There are even some packages that do not provide prebuild binaries at all and encourage only building from source on install. There starts the Windows specific problem due to the lack of OOTB C/C++ compiler. Other OSes don't have this challenge as C/C++, Python, Ruby etc. runtimes come preinstalled in most Unices.

We need a way to bundle these components into a single install

IMO, this experience can be much improved if we only get OTTB C/C++ compiler in Windows clients, as well as the ability to install or in-place upgrade standalone C++ build toolchain: VC compilers + libraries + dependencies (these are C/C++ build-tools related dependencies, not Python etc.), all this to match the degree of Clang/GCC readiness and availability on Unices.

Current requirements to install packages with native modules after fresh Windows installation: Visual Studio + Python 2.7.x + Node.js

Most Desired behavior: Standalone Build Tools + Pythons 2.7.x + Node.js (and ability to install everything via command-line, perhaps via: https://chocolatey.org/)

Maybe Desired Behavior: One magic box for all node.js build tools. Or a one-click web-installer, which will let users choose which runtimes are required.

set of npm packages that should work so we can ensure we don't miss anything

Here is a small list of commonly used packages with native module, which cover most of the nan surface area:

  • bson
  • bufferutil
  • kerberos
  • node-sass
  • node_sqlite3
  • phantomjs
  • utf-8-validate

am11 avatar Sep 30 '15 06:09 am11

Most Desired behavior: Standalone Build Tools + Pythons 2.7.x + Node.js

Most desired behavior for whom? Most desired behavior for package users should be "it just works", and for this a web service that builds, caches, and serves binaries makes the most sense (which I think is what is described here).

If you actually want to build from source yourself, then it's okay to have those requirements (although Python 2.7 is ancient), but not everyone wants/needs to do this.

glen-84 avatar Sep 30 '15 07:09 glen-84

I don't know if anything has changed in the last week or so, but I seem to have gotten everything working fine under the latest Node and NPM versions with a brand new Window 7 x64 Ultimate install in Virtualbox.

Unless I missed something all I did was install: Node 4.1.1 NPM v3.3.5 (updated using npm-windows-upgrade) Git 2.5.3.windows.1 Python 2.7.10 Visual Studio 2015 Community ConEmu (shell wrapper for various consoles)

At that point I was able to npm install a project with dependencies including webpack, webpack-dev-server, gulp, etc and I could see node-gyp building successfully.

I never had to set any environment variables or make any other special configurations. Not that it should matter, but I am using ConEmu with the Git Bash shell for most things. Modules that were installed globally (thus requiring administrative privileges) were installed using a standard CMD console with elevated privileges.

dlong500 avatar Sep 30 '15 08:09 dlong500

For the following error

C:\Development\GitHub\flux (master)
λ npm i
npm WARN engine [email protected]: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.7","npm":"3.2.2"})

> [email protected] install C:\Development\GitHub\flux\node_modules\contextify
> node-gyp rebuild


C:\Development\GitHub\flux\node_modules\contextify {git}
{lamb} if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Development\GitHub\flux\node_modules\contextify\build\contextify.vcxproj(20,3): error MSB4019: The imported project "C:\Program Files(x86)\MSBulid\Microsoft.Cpp\v4.0\v140\Microsoft.Cpp.Default.props" was not found. Confirm that the pa th in the <Import> declaration is correct, and that the file exists on disk.

Per @ProtomotoReal, all I had to do was SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140

Hopefully this helps someone.

andrewc89 avatar Oct 01 '15 13:10 andrewc89

For Windows 10 + VS2013 Ultimate - npm install was throwing this error:

F:\git\Coding\NasaDashboard\nasa-web-app\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Users\Gosha\AppData\Roaming\npm
node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild ) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(44,5): error MSB8020: The builds tools for v120 (Plat form Toolset = 'v120') cannot be found. To build using the v120 build tools, either click the Project menu or right-click the solution, and then select "Update VC++ Projects...". Install v120 to build using the v120 build tools. [F:\git\Coding\NasaDashboard\nasa-web-app\node_mo dules\kerberos\build\kerberos.vcxproj]

The suggested solution from @ProtomotoReal worked for me. In my NodeJS command prompt I ran

SET VCTargetsPath=C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120

Then npm install worked fine:

F:\git\Coding\NasaDashboard\nasa-web-app\node_modules\kerberos>if not defined npm_config_node_gyp (node "C:\Users\Gosha\AppData\Roaming\npm
node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node rebuild ) Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch. kerberos.cc worker.cc security_buffer.cc security_buffer_descriptor.cc security_context.cc security_credentials.cc base64.c kerberos_sspi.c win_delay_load_hook.c Creating library F:\git\Coding\NasaDashboard\nasa-web-app\node_modules\kerberos\build\Release\kerberos.lib and object F:\git\Coding\Na saDashboard\nasa-web-app\node_modules\kerberos\build\Release\kerberos.exp Generating code Finished generating code kerberos.vcxproj -> F:\git\Coding\NasaDashboard\nasa-web-app\node_modules\kerberos\build\Release\kerberos.node

gallak87 avatar Oct 04 '15 19:10 gallak87

+1 node-gyp is a real pain in the ass for Windows user. For instance if you want to do security you'll need bcrypt and so node-gyp so install a 2go IDE.

  • Why NodeJS Core didn't include node-gym in it's core ? It's already platform dependent
  • Why not providing (with Microsoft Help) a wrapper to install on Windows ?

JpEncausse avatar Oct 06 '15 09:10 JpEncausse

Why NodeJS Core didn't include node-gym in it's core ? It's already platform dependent

Assuming you meant "node-gyp". It is included with every installation of Node.js (as an npm dependency).

The problem is that you also need Python and Visual Studio. We (a few folks at Microsoft) are working to tackle this issue.

orangemocha avatar Oct 06 '15 14:10 orangemocha

node-gym :grey_exclamation: Is it someplace where all the node'ies do the exercise? :smile:

ghost avatar Oct 06 '15 18:10 ghost

Sorry for the typo. That would be SOOOO cool if a workaround allow a simple native npm install module It will still require an install, but it's a great step

JpEncausse avatar Oct 06 '15 21:10 JpEncausse

:+1: for this. All operating systems (mac, linux) have build tools (usable in this case) free for both private and commercial use, except of Windows. Now, to use node-sass, I have to install visual studio which is free only for private use. Minimum requirement for this is: a package which installs compilers, linkers, etc ... - without any additional components. Just SDK with tools used to build a binary addon. I don't know, maybe Windows SDK is suitable but I haven't found any manual how to set it up with node4.

antelle avatar Oct 07 '15 14:10 antelle

@antelle I'm absolutely for a minimal set of requirements and hope that Microsoft makes it much easier. That being said, Visual Studio Community edition is free for commercial use provided that your company is small (under $1 million in revenue and/or more than 250 PCs) and that 5 or fewer developers concurrently use the software. So it is certainly free for an individual to use commercially. In fact, if I'm reading the license right you could be the sole developer of some software (with no help) and still qualify for a free license even if you happen to bring in $1 million or more in annual revenue.

For open source or other non-commercial use it is free for anyone or any organization with no limitations.

Of course it would still be much better to have the basic compilers and build tools available as a continually supported Microsoft package to prevent the necessity of Visual Studio with its large footprint.

dlong500 avatar Oct 07 '15 14:10 dlong500

@dlong500, I work in a company, and we are not a small company. We develop a large commercial product: there are several C++ devs and plenty of front-end. We cannot use free visual studio, so the question is: Why do we have to spend additional $5000 for every front-end dev if none of them will ever open visual studio? Windows SDK is free, and it does include C++ compiler, so requiring VS for node-gyp is just a nonsense.

antelle avatar Oct 07 '15 15:10 antelle

@antelle, well yes if you are in a large company then it's not as simple. However, if you are only using the cli compilers I'm not sure if the same licensing restrictions would apply. Anyone from Microsoft willing to clarify?

Don't get me wrong, I completely agree with you as I said before. The SDK should be all that is needed, but in the meantime it would seem appropriate if Microsoft would allow compilers installed with VS community to be restriction free if used outside of VS.

dlong500 avatar Oct 07 '15 15:10 dlong500

Windows SDK is free, and it does include C++ compiler, so requiring VS for node-gyp is just a nonsense.

Wrong, I'm afraid. From https://msdn.microsoft.com/en-us/windows/desktop/bg162891.aspx:

The Windows SDK no longer ships with a complete command-line build environment. You must install a compiler and build environment separately. If you require a complete development environment that includes compilers and a build environment, you can download Visual Studio 2013, which includes the appropriate components of the Windows SDK.

bnoordhuis avatar Oct 07 '15 15:10 bnoordhuis

@dlong500 : you can use Visual Studio Express for Windows Desktop.

From https://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx

Commercial use of Express products Visual Studio Express products are available at no charge and may be used for commercial, production usage subject to the license terms provided with each product. For example, you can use Express for Windows to create apps that you can then submit for sale in the Windows Store.

orangemocha avatar Oct 07 '15 16:10 orangemocha

@bnoordhuis, thanks for the link. I was pretty sure it was still distributed with SDK (and is actually was used to be included before) but that is no longer true. Also found this question on stackoverflow. Yes, it seems, there's no way to get a free C++ compiler.

antelle avatar Oct 07 '15 20:10 antelle