nodejs / node-gyp

Node.js native addon build tool
MIT License
9.97k stars 1.8k forks source link

Windows users are not happy. #629

Closed luisrudge closed 8 years ago

luisrudge commented 9 years ago

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

erezcohen commented 9 years ago

@Sogl / @dekarguy - So to get it to work on Win7 still requires installing VS? SDK is not enough?

dekarguy commented 9 years ago

@erezcohen My guess is yes, at the very least the build tools, but I'm not sure if they will install the C++ Foundation headers. I don't have a clean machine available to test without Visual Studio since my whole team uses it for Windows development, just getting everything built with 2013 was enough for us.

Sogl commented 9 years ago

@erezcohen, SDK is enough, but you must use SDK console for installation. Tested on clean Win 8.1 virtual machine.

erezcohen commented 9 years ago

Thanks guys. Though I must say - this whole mess still seems unacceptable to me. I have to spill my guts here and also have a question - please bare with me...

This thread is titled "Windows users are not happy" - and indeed I'm unhappy still - Not that I don't appreciate the effort and contribution! NOTE: We're using node/npm as a build engine for our web app - not for server development. (Our dev environment is windows, though the server is java based).

I recently wanted to upgrade our node and than ran into this issue. Currently our continuous integration runs our unit tests multiple times a day on windows slaves. It's a simple environment that starts from a clean machine and installs, using few simple maven steps, node+grunt and execute the tests. The whole thing runs in less than 15 minutes. Throwing onto that the above MS stack (I'm using the word stack out of politeness..) is as I said unacceptable. The inevitable conclusion I made was that I'll either have to switch to unix or stay with an outdated node server. For now we chose the latter. This is actually working well for our needs so far, but of course this is not a sustainable solution. As far as I saw, the node-gyp was only used in our env by the (similarly outdated) grunt-sass package - which still does its job well. Which brings me to my questions:

  1. Why was this change done? (Found this - http://stackoverflow.com/questions/26959640/why-does-node-gyp-and-other-stuff-require-visual-studio - but unanswered)
  2. Could there be a way to use the previous mechanism with a new node? I mean perhaps enable running node with a flag to override this behavior?

Thanks and apologies...

bnoordhuis commented 9 years ago

Why was this change done? (Found this - http://stackoverflow.com/questions/26959640/why-does-node-gyp-and-other-stuff-require-visual-studio - but unanswered)

Because node-gyp needs a C++ compiler. Most platforms ship them by default but not Windows.

There has been talk of downloading and installing the compiler automatically. I understand that's the approach depot_tools takes.

am11 commented 9 years ago

Because node-gyp needs a C++ compiler. Most platforms ship them by default but not Windows

Agree and it requires GBs large VS to download in order to get the C++ compiler.

On this note, please give your +3 on this: http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/6742251-make-c-c-compiler-cl-exe-independent-of-ide, to convince the VC team. :)

afilp commented 9 years ago

@sogl and others... I also have Windows 10 and cannot make it work, because of the SDK 7 failure. Did you find any other solution? Thanks.

thorn0 commented 9 years ago

@af7 Did you install the C++ part of VS 2015? It includes the SDK.

afilp commented 9 years ago

@thorn0 Trying... because when trying to do so, I have to fight another (ridiculous) MS problem that does not even allow me to install VS 2015 using its own EXE installer!:

The "dreaded" message "A setup project is either missing or damaged"! (while Windows 10 are quite clean and the installer downloads all files from the MS website)

See another user mentioning it here: https://social.msdn.microsoft.com/Forums/en-US/c433f65f-02be-4a32-8175-24527d5447b9/a-setup-project-is-either-missing-or-damaged?forum=msbuild

So, my next approach is to wait for the 3.3GB of the ISO to be downloaded, cross my fingers, and hopefully VS 2015 gets installed.

Then, I will report back...

dekarguy commented 9 years ago

We have a couple coworkers who ended up getting everything working on Windows 10 and VS 2013. Make sure the VS 2010 redistributables are removed, run the SDK 7.1 installer, continue past the warnings that you have a beta version of the .NET framework (you can still continue the installer past this point) and see the installer to completion.

afilp commented 9 years ago

@dekarguy Aha! Tried this too! But then I get the other dreaded message from MS at the very beginning of the installation:

"Some components cannot be installed, blah blah blah, click OK to continue"

image

So, I did not want to continue, but I can assume from your valuable reporting that if I continue this may work. But then, do I really need the VS 2013 also installed? Because @Sogl above says that SDK 7.1 would be enough (along with Python, etc.).

I will try this now, ignoring the warning message.

UPDATE: No luck... So, I will now install the ISO of VS 2015 (still I have the SDK semi-installed, not sure is this will matter or not)

UPDATE 2: SUCCESS with installing the VS 2015 from its ISO. And node-gyp seems to be working now.

Sogl commented 9 years ago

Hm... guys, something changed in npm because now it not uses user profile folder! Found it on new virtual machines.

Just tested on clean VM with Windows 7 x64, VS not installed. Some output:

> utf-8-validate@1.1.0 install C:\nodejs\node_modules\browser-sync\node_modules\
utf-8-validate
> node-gyp rebuild

C:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate>if not defined n
pm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\nod
e_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Построение проектов в этом решении по одному. Чтобы включить параллельное постро
ение, добавьте параметр "/m".
  validation.cc
     Creating library C:\nodejs\node_modules\browser-sync\node_modules\utf-8-va
  lidate\build\Release\validation.lib and object C:\nodejs\node_modules\browser
  -sync\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> C:\nodejs\node_modules\browser-sync\node_modules\utf-8-
  validate\build\Release\\validation.node

> utf-8-validate@1.1.0 install C:\nodejs\node_modules\browser-sync\node_modules\
utf-8-validate
> node-gyp rebuild

C:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate>if not defined n
pm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\nod
e_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Построение проектов в этом решении по одному. Чтобы включить параллельное постро
ение, добавьте параметр "/m".
  validation.cc
     Creating library C:\nodejs\node_modules\browser-sync\node_modules\utf-8-va
  lidate\build\Release\validation.lib and object C:\nodejs\node_modules\browser
  -sync\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> C:\nodejs\node_modules\browser-sync\node_modules\utf-8-
  validate\build\Release\\validation.node

> bufferutil@1.1.0 install C:\nodejs\node_modules\browser-sync\node_modules\buff
erutil
> node-gyp rebuild

C:\nodejs\node_modules\browser-sync\node_modules\bufferutil>if not defined npm_c
onfig_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Построение проектов в этом решении по одному. Чтобы включить параллельное постро
ение, добавьте параметр "/m".
  bufferutil.cc
     Creating library C:\nodejs\node_modules\browser-sync\node_modules\bufferut
  il\build\Release\bufferutil.lib and object C:\nodejs\node_modules\browser-syn
  c\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\nodejs\node_modules\browser-sync\node_modules\buffer
  util\build\Release\\bufferutil.node

Before update npm on Windows 8.1 x64:

$ npm i -g browser-sync
npm WARN install Couldn't install optional dependency: Unsupported
C:\Users\Artyom\AppData\Roaming\npm\browser-sync -> C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-sync\bin\browser-sync.js

> bufferutil@1.1.0 install C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\bufferutil
> node-gyp rebuild

Артем@SOGL C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\bufferutil
$ if not defined npm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  bufferutil.cc
     Creating library C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-
  sync\node_modules\bufferutil\build\Release\bufferutil.lib and object C:\Users
  \Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\bufferutil
  \build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> C:\Users\Artyom\AppData\Roaming\npm\node_modules\browse
  r-sync\node_modules\bufferutil\build\Release\\bufferutil.node

> utf-8-validate@1.1.0 install C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\utf-8-validate
> node-gyp rebuild

Артем@SOGL C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\utf-8-validate
$ if not defined npm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  validation.cc
     Creating library C:\Users\Artyom\AppData\Roaming\npm\node_modules\browser-
  sync\node_modules\utf-8-validate\build\Release\validation.lib and object C:\U
  sers\Artyom\AppData\Roaming\npm\node_modules\browser-sync\node_modules\utf-8-
  validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> C:\Users\Artyom\AppData\Roaming\npm\node_modules\browse
  r-sync\node_modules\utf-8-validate\build\Release\\validation.node

And after update from npm 3.2.0 to 3.2.2 on host machine with Windows 8 x64:

$ npm i -g browser-sync
npm WARN install Couldn't install optional dependency: Unsupported
c:\nodejs\browser-sync -> c:\nodejs\node_modules\browser-sync\bin\browser-sync.js

> bufferutil@1.1.0 install c:\nodejs\node_modules\browser-sync\node_modules\bufferutil
> node-gyp rebuild

Артем@SOGL c:\nodejs\node_modules\browser-sync\node_modules\bufferutil
$ if not defined npm_config_node_gyp (node "c:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  bufferutil.cc
     Creating library c:\nodejs\node_modules\browser-sync\node_modules\bufferut
  il\build\Release\bufferutil.lib and object c:\nodejs\node_modules\browser-syn
  c\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> c:\nodejs\node_modules\browser-sync\node_modules\buffer
  util\build\Release\\bufferutil.node

> utf-8-validate@1.1.0 install c:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate
> node-gyp rebuild

Артем@SOGL c:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate
$ if not defined npm_config_node_gyp (node "c:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  validation.cc
     Creating library c:\nodejs\node_modules\browser-sync\node_modules\utf-8-va
  lidate\build\Release\validation.lib and object c:\nodejs\node_modules\browser
  -sync\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> c:\nodejs\node_modules\browser-sync\node_modules\utf-8-
  validate\build\Release\\validation.node

> bufferutil@1.1.0 install c:\nodejs\node_modules\browser-sync\node_modules\bufferutil
> node-gyp rebuild

Артем@SOGL c:\nodejs\node_modules\browser-sync\node_modules\bufferutil
$ if not defined npm_config_node_gyp (node "c:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  bufferutil.cc
     Creating library c:\nodejs\node_modules\browser-sync\node_modules\bufferut
  il\build\Release\bufferutil.lib and object c:\nodejs\node_modules\browser-syn
  c\node_modules\bufferutil\build\Release\bufferutil.exp
  Generating code
  Finished generating code
  bufferutil.vcxproj -> c:\nodejs\node_modules\browser-sync\node_modules\buffer
  util\build\Release\\bufferutil.node

> utf-8-validate@1.1.0 install c:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate
> node-gyp rebuild

Артем@SOGL c:\nodejs\node_modules\browser-sync\node_modules\utf-8-validate
$ if not defined npm_config_node_gyp (node "c:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Сборка проектов в этом решении по одному. Чтобы включить параллельную сборку, добавьте параметр "/m".
  validation.cc
     Creating library c:\nodejs\node_modules\browser-sync\node_modules\utf-8-va
  lidate\build\Release\validation.lib and object c:\nodejs\node_modules\browser
  -sync\node_modules\utf-8-validate\build\Release\validation.exp
  Generating code
  Finished generating code
  validation.vcxproj -> c:\nodejs\node_modules\browser-sync\node_modules\utf-8-
  validate\build\Release\\validation.node

As you can see, global modules now install in your node.js folder, not in AppData.

@af7 If you can't install SDK 7.1 full, use VS 2013/2015. With this warning SDK not install C++ compilers that we need to compile.

Sogl commented 9 years ago

I created a profile in Windows 7 x64 with RU letters, digits, etc: артем_12312_() and installation failed (same v8.h error):

C:\Windows\system32>whoami
artyom-pc\артем_12312_()

C:\Windows\system32>npm i -g browser-sync
npm WARN install Couldn't install optional dependency: Unsupported
C:\nodejs\browser-sync -> C:\nodejs\node_modules\browser-sync\bin\browser-sync.j
s

> bufferutil@1.1.0 install C:\nodejs\node_modules\browser-sync\node_modules\buff
erutil
> node-gyp rebuild

C:\nodejs\node_modules\browser-sync\node_modules\bufferutil>if not defined npm_c
onfig_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_mo
dules\node-gyp\bin\node-gyp.js" rebuild )  else (node  rebuild )
Построение проектов в этом решении по одному. Чтобы включить параллельное постро
ение, добавьте параметр "/m".
  bufferutil.cc
..\src\bufferutil.cc(7): fatal error C1083: Cannot open include file: 'v8.h': N
o such file or directory [C:\nodejs\node_modules\browser-sync\node_modules\buff
erutil\build\bufferutil.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\nodejs\node_modules\npm\node_modul
es\node-gyp\lib\build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074
:12)
gyp ERR! System Windows_NT 6.1.7600
gyp ERR! command "node" "C:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\nodejs\node_modules\browser-sync\node_modules\bufferutil
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN EPACKAGEJSON C:\nodejs No description
npm WARN EPACKAGEJSON C:\nodejs No repository field.
npm WARN EPACKAGEJSON C:\nodejs No README data
npm WARN EPACKAGEJSON C:\nodejs No license field.
npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-
cli.js" "i" "-g" "browser-sync"
npm ERR! node v0.12.7
npm ERR! npm  v3.2.0
npm ERR! code ELIFECYCLE

npm ERR! bufferutil@1.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bufferutil@1.1.0 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the bufferutil package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls bufferutil
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Windows\system32\npm-debug.log

C:\Windows\system32>

But artyom_000 username works =)

Also SO question about SDK installation error created: https://stackoverflow.com/questions/32423090/cant-install-windows-7-sdk-require-already-installed-net-framework-4

Sogl commented 9 years ago

Found solution for Windows 7, Windows 8 and Windows 10. Tested on clean x64 installations. Visual Studio not required.

You need only these tools:

Steps:

  1. If you profile contains non-ASCII characters, rename it or create the other one.
  2. Install Node. I use C:\nodejs folder.
  3. Update npm from 2.* to 3.*: 3.1. npm i -g npm@3.2.2 3.2. cd C:\nodejs 3.3. npm i npm@3.2.2 3.4. npm -v (must be 3.2.2)
  4. Install python 2.7.9 and choose add to PATH in installation. After install python command in console should work. If not, reboot your PC or repair installation.
  5. Download and install Windows SDK 7. Choose GRMSDKX_EN_DVD.iso for x64 and GRMSDK_EN_DVD.iso for x86. All checkboxes by default. If you see error Some components cannot be installed (especially on Windows 10), install SDK from Setup/SDKSetup.exe. More info.
  6. Use SDK 7.1 console for node modules installation.

That's all.

It would be nice if somebody helps me with PATH variables to use native command prompt.

donaldhook commented 9 years ago

awesome!

On Mon, Sep 7, 2015 at 6:41 AM, Artyom Mezin notifications@github.com wrote:

Found solution for Windows 7, Windows 8 and Windows 10. Tested on clean x64 installations. Visual Studio not required.

You need only these tools:

  • Node.js v 0.12.7
  • npm 3.2.0 or higher
  • Python 2.7.9
  • SDK for Windows 7 (no need SP1, in most situations all works without it)

Steps:

  1. If you profile contains non-ASCII characters, rename it or create the other one.
  2. Install Node. I use C:\nodejs folder.
  3. Update npm from 2.* to 3.*:

It would be nice if somebody helps me with PATH variables to use native command prompt.

— Reply to this email directly or view it on GitHub https://github.com/nodejs/node-gyp/issues/629#issuecomment-138276692.

am11 commented 9 years ago

@Sogl, thanks for the steps!

It would be nice if somebody helps me with PATH variables to use native command prompt.

To have MSBuild that installs with VS2015, you may want to add %ProgramFiles(x86)%\MSbuild\14.0\Bin to PATH.

In case you have multiple versions of VS installed, you can explicitly specify VS2013's MSBuild (when VS2015 is in PATH), use %ProgramFiles(x86)%\MSbuild\12.0\Bin\MSBuild build\solution_name.sln or its PowerShell variant ${env:ProgramFiles(x86)}/MSBuild/12.0/Bin/MSBuild build/solution_name.sln. I know fingers hurt typing it everytime, but I am used to it now. :)

marco-faustinelli commented 9 years ago

Here's my solution. Hope it can help someone.

After wasting two evenings of own free time staring at the same error in a PowerShell window

gyp ERR! stack     at ChildProcess.onExit (C:\ProgramFiles\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)

this morning I went working from an old-fashioned CMD window as administrator, and magically it all worked just fine.

I am using Windows 7 Professional edition, VS 2015 with all the C++ jazz, Python 2.7 in C:\Python27 (with env var PYTHON), no special MS packages and the variable

GYP_MSVS_VERSION=2015

set from the control panel, just like fifteen years ago.

This is the crappiest situation I've met in the last couple of years.

I am aware that setting env vars in the CMD window is not the same as in PowerShell, but I had all the vars in both environments, and only the one in CMD worked.

dvf commented 9 years ago

Working Solution on Windows 10

Can confirm @marco-faustinelli is right.

At long last, I was able to npm install -g socket.io from an elevated CMD prompt and install socket.io.

Sogl commented 9 years ago

@vanflymen , In your solution we need to download ~4 GB VS2015 and install it only for build cpp files... My solution is better I think.

dekarguy commented 9 years ago

@Sogl That solution works great (Thank you!) if you don't have to integrate it into an environment where other versions of visual studio are in active use and are ok with always using the SDK command prompt @marco-faustinelli @vanflymen Does that solution bypass the requirement for the Windows 7.1 SDK, and does it work on other Windows versions? (7/8/8.1)

dvf commented 9 years ago

I did a clean format of Windows 10, installed Python 2.7.10 and the newly released nodejs v4.0.0 and everything seems like it works. node-gyp is finally working too.

I still can't install socket.io but it looks like some dependencies haven't been updated yet.

PS. Without Visual Studio.

johanalkstal commented 9 years ago

Maybe that has to do with the new bundling of node-gyp into node 4.0.0?

"node-gyp: This release bundles an updated version of node-gyp that works with all versions of Node.js and io.js including nightly and release candidate builds. From io.js v3 and Node.js v4 onward, it will only download a headers tarball when building addons rather than the entire source."

johanalkstal commented 9 years ago

Haven't tried it yet myself.

orangemocha commented 9 years ago

Sorry to see all this frustration with using node-gyp on Windows :unamused:

While it might take some time to implement, we are pursuing a solution that will eliminate the need to have VS installed when installing native modules: https://github.com/nodejs/build/issues/151

luisrudge commented 9 years ago

awesome @orangemocha. I'm glad someone is looking at this!

Pharylon commented 9 years ago

I just want to say... this is hell. I've installed several things trying to fix it, about to roll back to a safer system restore to try some more things. But seriously....

Pharylon commented 9 years ago

OK, so here's how I fixed my issue and got node-gyp building with Visual Studio 2015 installed.

  1. Be on version 0.12.2. This breaks completely on 4.0. However, v0.12.2 is what the the Visual Studio 2015 installer will install if you ask it to install Node.js.
  2. Make sure the C++ components of Visual Studio 2015 are installed. If you're not sure, run the installer and check.
  3. Update NPM using npm-windows-update.

That got it working for me, I'm able to sucessfully build sockiet.io.

rainabba commented 9 years ago

@Pharylon Lucky you. npm-windows-update just hosed my system: https://github.com/felixrieseberg/npm-windows-upgrade/issues/34

srlowe commented 9 years ago

Since upgrading to node4 with node-gyp v3.0.3 I'm having even more issues than before. Packages that previously installed ok are now failing. Really sick of this TBH.

aahoo commented 9 years ago

@bgSosh same for me! now trying to figure out how to go back.

dperu commented 9 years ago

Just shoot me!

The x64 compilers are not currently installed. Please go to Add/Remove Programs to update your installation. Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.0. Targeting Windows 7 x64 DEBUG C:\Program Files\Microsoft SDKs\Windows\v7.0>cd \tmp4 C:\tmp4>cd node-buffertools C:\tmp4\node-buffertools>node-gyp rebuild gyp info it worked if it ends with ok gyp info using node-gyp@3.0.3 gyp info using node@4.0.0 | win32 | x64 gyp info spawn python gyp info spawn args [ 'D:\Software\NodeJS_npm\node_modules\node-gyp\gyp\gyp_main.py', gyp info spawn args 'binding.gyp', gyp info spawn args '-f', gyp info spawn args 'msvs', gyp info spawn args '-G', gyp info spawn args 'msvs_version=auto', gyp info spawn args '-I', gyp info spawn args 'C:\tmp4\node-buffertools\build\config.gypi', gyp info spawn args '-I', gyp info spawn args 'D:\Software\NodeJS_npm\node_modules\node-gyp\addon.gypi', gyp info spawn args '-I', gyp info spawn args 'C:\Users\Dave2.node-gyp\4.0.0\include\node\common.gypi', gyp info spawn args '-Dlibrary=shared_library', gyp info spawn args '-Dvisibility=default', gyp info spawn args '-Dnode_root_dir=C:\Users\Dave2.node-gyp\4.0.0', gyp info spawn args '-Dnode_gyp_dir=D:\Software\NodeJS_npm\node_modules\node-gyp', gyp info spawn args '-Dnode_lib_file=node.lib', gyp info spawn args '-Dmodule_root_dir=C:\tmp4\node-buffertools', gyp info spawn args '--depth=.', gyp info spawn args '--no-parallel', gyp info spawn args '--generator-output', gyp info spawn args 'C:\tmp4\node-buffertools\build', gyp info spawn args '-Goutput_dir=.' ] gyp info spawn msbuild gyp info spawn args [ 'build/binding.sln', gyp info spawn args '/clp:Verbosity=minimal', gyp info spawn args '/nologo', gyp info spawn args '/p:Configuration=Release;Platform=x64' ] C:\tmp4\node-buffertools\build\buffertools.vcxproj(3,14): error MSB4066: The attribute "Label" in element is unrecogn ized. gyp ERR! build error gyp ERR! stack Error: msbuild failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (D:\Software\NodeJS_npm\node_modules\node-gyp\lib\build.js:270:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "C:\Program Files\nodejs\node.exe" "D:\Software\NodeJS_npm\node_modules\node-gyp\bin\node-gyp.js" "rebui ld" gyp ERR! cwd C:\tmp4\node-buffertools gyp ERR! node -v v4.0.0 gyp ERR! node-gyp -v v3.0.3 gyp ERR! not ok

C:\tmp4\node-buffertools>

I love NodeJS. I really do.

rainabba commented 9 years ago

@dperu BANG!!! You're confusing Node.js with NPM with node-gyp. This issue has nothing to do with node and everything to do with how developers are creating their modules; using platform-specific approaches and existing code-bases that have to be compiled. node-gyp is a tool they use to help automate that process (think tar-ball).

Sadly, too many developers don't use node as they should and then there are cases where they don't want to recreate (perhaps rightfully so) code in node.js that's already setup for something like c++ or another language and it has to be compiled. @TooTallNate (along with other developers/maintainers of node-gyp) have taken on quite the task in supporting those use-cases and really shouldn't be faulted. It's really up to the community to reduce their dependence on non-node solutions.

At least, that's my opinion based on what little I know :P Take it with a grain of salt.

dperu commented 9 years ago

@rainabba You are right, it's more a npm and node-gyp issue. You are right about not being faulted. I am actually thankful to the other developers who are making C++ contributions. It's been 17 years since I've compiled a C++ program. I'm coming from a C# background. But at this point I am in the process of switching stacks. I really like NodeJS and the JavaScript programming language. This particular issue is frustrating though but I imagine at some point I will be able to hack it out with all the helpful blog posts.

srlowe commented 9 years ago

@Sogl I like your minimal solution, but have you been able to get it to work with node4?

dperu commented 9 years ago

@Sogl This is how the problem started for me. I was using node4 with node-gyp v3.0.3. And I started loading older versions. My current thinking on the problem is the PATH variable is not using the correct location for MSBUILD but I was busy at work and I did not get a chance to test it. In the command prompt you can enter the command: "where msbuild" to see the path location.

dperu commented 9 years ago

So here is what I discovered. I followed the other blog posts and installed Windows SDK 7. When I launch the SDK 7 command prompt having the "SetEnv.cmd" I still got errors. Here is what I was orginally trying to do from the command prompt:

C:\tmp4\npm install -g buffertools

But this failed miserablly. Then after reading some posts I did the following:

C:\tmp4> git clone https://github.com/bnoordhuis/node-buffertools C:\tmp4> cd node-buffertools C:\tmp4\node-buffertools> node-gyp rebuild

This gave me some additional error information. That information seem to indicate I was using the wrong version of MSBUILD. So I did the following:

C:\tmp4\node-buffertools> where msbuild C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild.exe C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe C:\Windows\Microsoft.NET\Framework64\v2.0.50727\MSBuild.exe C:\Windows\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe

I needed a version of SDK 7 which support the Framework\v4.0.30319. But when I installed SDK 7.1 which is supposed to support Framework\v4.0.30319 it did not create a "C:\Program Files\Microsoft SDKs\Windows\v7.1\bin" folder as I would expect. Even though the installer said it would create the directory but it did not. And I did run the installer in Administrator mode.

So my next step was to launch the 7.0 command prompt and change the PATH. Here's the 7.0 command prompt:

C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd"

I created a desktop icon for this, and then right-clicked and selected "Run as administrator" from the popup menu. I did the following command from the command prompt:

C:\tmp4> set PATH=C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Windows\Microsoft.NET\Framework\v4.0.30319;%PATH%

So when you do "where msbuild" from the command prompt, the V4.0.30319 version was first on the list. Then I was able to do all the following with no errors:

C:\tmp4> cd node-buffertools C:\tmp4\node-buffertools> node-gyp rebuild C:\tmp4\npm install -g buffertools

C:\tmp4\npm install -g strongloop // My original intention of my efforts! Success!

One little gotcha when I got started. After you install NodeJS, you should edit the following file:

C:\Program Files\nodejs\node_modules\npm\npmrc

Change the following:

prefix=%APPDATA%\npm

To the following (or some other appropriate location):

prefix=c:\NodeJS_npm

Then I put the directory "c:\NodeJS_npm" in my PATH so the installed node modules can execute.

So this command now works:

C:\tmp4> slc loopback

am11 commented 9 years ago

IMO, doWhich function should be removed and its usage should be replaced by findMsbuild().

findMsbuild always attempts to get the latest ToolsVersion installed first, instead of selecting the one present in the PATH; which in some cases corresponds to older version. It certainly depends on the combination of installed software, for instance; it is happening in my setup very often where I normally only install a latest VS but some other runtimes setup installs old VS redistribution packs (vs2013 etc.) as well as "partial MSBuild" (v12.0 with no supporting VC libs and 14.0 targets support) installation. Currently in my setup, PATH in Git for Windows PowerShell instance suggests:

# in PowerShell
C:\> (gcm msbuild).Version          # see http://stackoverflow.com/a/32522462/863980

Major  Minor  Build  Revision
-----  -----  -----  --------
12     0      31010  0

# (now I have manually set PATH to %ProgramFiles(x86)\MSBuild\14.0\Bin% in System >
# Environment Variables settings)

This change might result in performance degradation by few [milli]seconds per build, but I think it is important for correctness.

Alternatively, perhaps make the doWhich OR findMSBuild function selection optional controlled by an additional environment variable knob like $env:GYP_USE_LATEST_MSBULD=1.

glen-84 commented 9 years ago

@orangemocha,

Does it also eliminate the need for Python?

I'm quite new to Node, and it seems crazy to me that I have to build things that are installed via packages.

Sogl commented 9 years ago

@bgSosh I haven't tried node 4 installation, but so sad to hear that problems remain.

orangemocha commented 9 years ago

Does it also eliminate the need for Python?

It would be good to eliminate that dependency too. Ideally you'd just need what comes with the Node installer (Node.exe + npm) and then npm install would just work.

Pharylon commented 9 years ago

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. :\

dekarguy commented 9 years ago

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

mousetraps commented 9 years ago

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:

luisrudge commented 9 years ago

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

am11 commented 9 years ago

@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:

glen-84 commented 9 years ago

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.

dlong500 commented 9 years ago

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.

andrewc89 commented 9 years ago

For the following error

C:\Development\GitHub\flux (master)
λ npm i
npm WARN engine jest-cli@0.1.18: wanted: {"node":"0.8.x || 0.10.x"} (current: {"node":"0.12.7","npm":"3.2.2"})

> contextify@0.1.14 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.

gallak87 commented 9 years ago

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

JpEncausse commented 9 years ago

+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.