1

Aloha stackoverflowers. I have spent approximately 20 hours researching and attempting to build NodeJS modules under Windows 7. Research topics have included the many famous threads on node-gyp, including the "TooTallNate" threads. Most of the advice threads go something like this:

  • Uninstall all visual studio and vs libraries completely off the development machine
  • Uninstall all VS re-distributables as well just to be safe (they can be re-instaleld later).
  • Re-install visual studio (take your pic, the tutorials all say that vs2010, vs2012, vs2013, or express version of any of these work)
  • Re-install libraries (Specifically the Windows SDK 7.1 is mentioned a lot)
  • Launch a command prompt using the visual studio shortcut to autopopulated environment variables and path
  • Use the --msvs_version=vsxxxx (where xxx is the year of your visual studio version) option when building.

I have tried

  • VS2008 (Full)
  • VS2008 (Express)
  • VS2010 (Full)
  • VS2010 (Express)
  • VS2012 (Express)
  • VS2013 (Express)

I have also tried (making no difference whatsoever):

  • NodeJS 32-bit
  • NodeJS 64-bit

Apparently getting node-gyp to compile is not the issue, as "npm install node-gyp@latest -g" executes with zero warnings. I have installed NodeJS for windows.

C:\myproject\node_modules\node-hid>npm -v
2.14.3

C:\myproject\node_modules\node-hid>node -v
v4.0.0

C:\myproject\node_modules\node-hid>node-gyp -v
v3.0.3

Python is at 2.7 and I have registered it's location with npm and node-gyp

But no matter what, I am not able to compile node modules such as node-hid, keytar, etc. without receiving a multitude of various compiler errors, usually related to something it doesn't like in various .h files.

Here's my attempt with VS2013:

cd c:\myproject\node_modules\
C:\myproject\node_modules>git --recursive https://github.com/node-hid/node-hid.git
cd node-git
C:\myproject\node_modules\node-hid>node-gyp build --msvs_version=2013
\\Let the code spew begin!

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 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.
hidapi.vcxproj -> C:\my_project\node_modules\node-hid\build\Release\
hidapi.lib
HID.cc
..\src\HID.cc(51): error C3861: 'NanThrowError': identifier not found [C:\TEMP\myproject\node_modules\node-hid\build\HID.vcxproj]
..\src\HID.cc(67): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) [C:\my_project\node_modules\node-hid\build\HID.vcxproj]
..\src\HID.cc(70): warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow) [C:\my_project\node_modules\node-hid\build\HID.vcxproj]
..\src\HID.cc(92): error C2061: syntax error : identifier 'NanCallback' [C:\my_project\node_modules\node-hid\build\HID.vcxproj]
..\src\HID.cc(106): error C2143: syntax error : missing ';' before '*' [C:\my_project\node_modules\node-hid\build\HID.vcxproj]

.... (the list goes on)

When I tried VS2008/VS2008 express, I received warnings that stdint.h was missing. I tried several stdint.h's that were contributed by the community, including one in the NodeJS distribution for Windows that was actually named "stdint-msvc2008.h". No matter which stdint.h I put into VS2008's include folder, I would get a huge explosion of angry warnings regarding mismatches etc.

When I tried to build on VS2010, I would get a generic MSBxxxx warning about labels.

When I tried VS2013 I get a lot of "nanthrowerror" messages. I get the same "nan.h" related error messages for various node_modules I try to build.

All of the help files and Windows with NodeJS advice and help threads that I find seem revolved around helping developers solve environment/variable issues, helping them install VS in the correct order, helping them install node-gyp and helping them use the correct --msvs_version=vsxxx tag. As far as I can tell, none of these are my issue. I don't get any warnings about a missing vcbuild.exe or missing msbuild.exe, it is indeed trying to compile using the Visual Studio Express installation on my machine, but I am missing something.

First off, what can I do to help provide more information on my question?

Related threads and references:

(I have more links to share, but it says my reputation is not high enough)

Community
  • 1
  • 1

2 Answers2

0

You're using the pre-4.0 syntax of NaN with a 4.0 node release. They just changed everything and it bit me pretty bad. NanThrowError is now Nan::ThrowError, etc...

There is helpful information in here: https://github.com/nodejs/nan/issues/402

And I found the regexes here: https://github.com/nodejs/nan/issues/376#issuecomment-120838432 to be extremely helpful in converting.

You should also read through the docs at https://github.com/nodejs/nan which are incomplete, but still the best thing going right now.

0

Solution:

Uninstall NodeJS 4.0.x for Windows.

Install NodeJS 0.10.x, 0.11.x, or 0.12.x for Windows.

Being a newbie to NodeJS, I didn't realize that any two given versions of NodeJS are likely incompatible with each other. 0.10.x to 0.11.x apparently involved a major change to the underlying engine, which caused any modules written for 0.10.x to stop working with 0.11.x.

If you found this thread, just know that 99% of your problems with any NodeJS project will involve getting all of your dependencies from around the same date code. Meaning if your NodeJS core is from let's say March 2014, then any modules you install should be from around that say time frame or else you'll probably have problems. Same goes for any other tools like Atom Electron -- always grab a version that has the same release date as your node core.