15

My attempts to use node-gyp on a Windows 7 + Node.js platform have failed [3] when attempting to compile the standard "Hello World" example [2]. Note: node-gyp is failing in a similar manner [3] when attempting npm install contextify w or w/o the "-g", thus these could be related issues.

Configuration:

  • node-gyp 0.12.2
  • Windows 7 x64 SP1
  • Python 2.7
  • Node.js 0.10.24
  • Visual Studio 2010 per [1] (also tried 2012)
  • VS SDK 7.1 per [1] (tried 32 and 64 bit versions)
  • running node-gyp from standard Windows Command Prompt or SDK7.1 cmd prompt

Refs:
[1] https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup

[2] https://github.com/joyent/node/tree/master/test/addons/hello-world

[3] "node-gyp rebuild" on "hello world"[2] project produces following 2 errors:

....node-gyp\0.10.24\deps\uv\include\win.h(8738): error C2371: 'SYSTEM_POWER_STATUS' : redefinition; different basic types [...\build\test.vcxproj]

....node-gyp\0.10.24\deps\uv\include\mswsock.h(27): fatal error C 1083: Cannot open include file: '_mingw.h': No such file or directory [...\build\test.vcxproj]

and following 2 warnings:

....node-gyp\0.10.24\deps\uv\include\win.h(13513): warning C4005: 'UNALIGNED' : macro redefinition [...\build\test.vcxproj]

....node-gyp\0.10.24\deps\uv\include\mswsock.h(26): warning C4068 : unknown pragma [...\build\test.vcxproj]

The full trace follows:

C:\sigma\node_modules\x>node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@0.12.2
gyp info using node@0.10.24 | win32 | x64
gyp info spawn python
gyp info spawn args [ 'C:\\Users\\Anybody\\AppData\\Roaming\\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:\\sigma\\node_modules\\x\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Anybody\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\Anybody\\.node-gyp\\0.10.24\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\Anybody\\.node-gyp\\0.10.24',
gyp info spawn args   '-Dmodule_root_dir=C:\\sigma\\node_modules\\x',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--generator-output',
gyp info spawn args   'C:\\sigma\\node_modules\\x\\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' ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.  test.cpp
C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\win.h(8738): error C2371: 'SYSTEM_POWER_STATUS' : redefinition; different basic types [C:\sigma\node_modules\x\build\test.vcxproj]  C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\win.h(8737) : see declaration of 'SYSTEM_POWER_STATUS'

C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\win.h(13513): warning C4005: 'UNALIGNED' : macro redefinition [C:\sigma\node_modules\x\build\test.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\crtdef s.h(502) : see previous definition of 'UNALIGNED'

C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\mswsock.h(26): warning C4068 : unknown pragma [C:\sigma\node_modules\x\build\test.vcxproj] C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\_mingw.h(33): warning C4068: unknown pragma [C:\sigma\node_modules\x\build\test.vcxproj]

C:\Users\Anybody\.node-gyp\0.10.24\deps\uv\include\_mingw.h(51): fatal error C1 189: #error :  ERROR: You must use a GNU Compiler. [C:\sigma\node_modules\x\build\test.vcxproj]

gyp ERR! build error
gyp ERR! stack Error: msbuild failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Users\Anybody\AppData\Roaming\npm\
node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Users\\Anybody\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\sigma\node_modules\x
gyp ERR! node -v v0.10.24
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok   
Colin D Bennett
  • 11,294
  • 5
  • 49
  • 66
user3208880
  • 151
  • 1
  • 1
  • 4
  • I am suffering from the same problem ~ I followed all the steps from **[Refs[1]](https://github.com/TooTallNate/node-gyp/wiki/Visual-Studio-2010-Setup)**, did you solved it? if so please share. – Imran Bughio May 22 '14 at 15:35
  • Please add your user experience to this issue: https://github.com/TooTallNate/node-gyp/issues/662 maybe they add a proper installer if more people join to this. – inf3rno Jul 09 '15 at 20:53

3 Answers3

9

Although this question is one month old, i ended up searching across the web and this was part of search results.

So here is a not-should-do-but-it-works answer.

First, i'm not familiar with node-gyp or the whole visual studio compile and stuff, i really really feel sorry for node-gyp depending on python (a really silent WTF )

So for no known reason nodejs version older than 0.10.22 (i'm running that now so i assume there it where it starts)

If you search your system for the file "uv.h" you might get some results IF you have previously installed nodejs versions, otherwise you could keep reading.

my previous 0.10.3 nodejs version had uv.h into node-gyp some like

<DRIVERLETTER>:\Users\<USERNAME>\.node-gyp\0.10.3\deps\uv

so if you read the npm documentation you will find the the argument on npm install

The --nodedir=/path/to/node/source argument will allow npm to find the node source code so that npm can compile native modules.

so the final command should be

npm install <package> --nodedir="<DRIVERLETTER>:\Users\<USERNAME\.node-gyp\0.10.3"

you might get some warnings but it should complete with success.

Gntem
  • 6,949
  • 2
  • 35
  • 48
  • i don't have `0.10.3` version but i did found `uv.h` file in the `0.10.21` version -- trying to install `jsdom` module -- still same error. – Imran Bughio May 22 '14 at 15:41
  • 20
    +1 for WTF. Node-gyp on windows7 is biggest shame which drops large shadow on node usability itself. – setec Oct 09 '14 at 14:15
  • `--nodedir` should be specified till `\dep\uv` such as `--nodedir=":\Users\ – Sithu Nov 21 '14 at 07:28
  • 2
    Have to agree with @setec . Also, Windows is terrible. – blong May 28 '15 at 20:40
  • This might be of some help to anyone trying to resolve this issue: https://www.robertkehoe.com/2015/03/fix-node-gyp-rebuild-error-on-windows/ – blong May 28 '15 at 20:48
  • It is also now possible to run without VS as they're offering independent windows c compilers in the win SDK again. And there's no shame in having a Python dependency. Those guys have had windows shenanigans covered for years. – Erik Reppen Oct 09 '15 at 23:41
1

Before you do anything, update Node and NPM by installing from the the node website (updating node and npm via npm appears to be busted on Windows. I'm not sure those delete-and-reinstall-everything-in-order instructions are current but that would most certainly be a major PITA which was what inspired me to look for alternatives given that that post was a little old in node years.

Ultimately, this resolved an issue for me with node-gyp as a dependency for the pg module and it ran with vs 2013, I believe (or at least that's what it appeared to be looking for before it started working).

Erik Reppen
  • 4,605
  • 1
  • 22
  • 26
  • I struggled with this for days on multiple machines and installing VS2013 was what finally fixed it. – Alex C Sep 22 '15 at 03:54
0

This is what helped me resolve it:

For some reason i had node-gyp in two different directories.

Directory 1:

C:\Users\Imran Bughio\.node-gyp\0.10.21\

Directory 2:

C:\Users\Imran Bughio\Documents\.node-gyp\0.10.21\


In 2nd directory i had a uv folder inside deps folder but that folder was not there in 1st directory.

Here is the path -- note it had uv.h file inside.

C:\Users\Imran Bughio\.node-gyp\0.10.21\deps\uv

SOLUTION:

I simply moved the uv & all the other extra folders from directory 2 to directory 1.

@Phoenix answer gave me a little hint, which ultimately helped me resolve this so, Thanks Phoenix.

Imran Bughio
  • 4,811
  • 2
  • 30
  • 53