I
I
Interface2015-05-17 12:48:43
css
Interface, 2015-05-17 12:48:43

How to properly install node addons with native code?

The problem pops up every time I try to install a non-standard (unpopular) module for node/io.js.
Its essence is simple: I write (windows 7 x64)

npm install smth

and the console gives me errors - I go to see what dependencies this module has on github, I try to fix them - the errors still remain.
The description, of course, is very chaotic and gives the impression that I just have crooked hands .. but can't this be done somehow easier?
Maybe there is some kind of analogue of npm that solves dependency problems for native modules?
Or perhaps one that would give binaries?
Due to the fact that I was trying to solve this problem, some porridge from Visual Studio of different versions arose on the main system, so in order to avoid unnecessary errors because of this, I decided to transfer the addon installation process to a virtual machine. Those. the plan is this:
  • a native module was required on the main machine
  • I go to the virtual one, install the module, it compiles. I have binaries of this module
  • I drag them to the main machine

for this I now have:
VMWare, on which:
  • Windows XP x32 (selected as less power hungry)
  • io.js (because node didn't want to start, claiming it's not an x32 app)
  • node-gyp
  • Visual studio C++ 2010 express
  • Python 2.7.9

However, all this still does not work for me when installing the current extension, namely: https://github.com/mikeseven/node-glfw
I acted again according to the instructions on the given page, but the attempts end:
... many errors...
.\src\glfw.cc(82): error C3861: 'NewSymbol': identifier not found [C:\Document
and Settings\user\1\node_modules\node-glfw\build\glfw .vcxproj]
... many errors ...
C:\Documents and Settings\user\1\node_modules\node-glfw\node_modules\nan\nan.h(
746): error C3861: 'NewSymbol': identifier not found [ C:\Documents and Settings
\user\1\node_modules\node-glfw\build\glfw.vcxproj]
C:\Documents and Settings\user\1\node_modules\node-glfw\node_modules\nan\nan.h(
750) : error C2039: 'NewSymbol' : is not a member of 'v8::String' [C:\Documents
and Settings\user\1\node_modules\node-glfw\build\glfw.vcxproj]
... many errors .. .
(I can provide all the output if needed)

Anyone can advise something?
Maybe I need Win7/8?
Studio 2013?
Any alternatives to npm/node-gyp?
Maybe you need to use node.js and iojs - not an option?
Maybe it's better to go to Linux?
Is it possible to cross-compile modules installed from npm from under Linux so that they can be run on win?
(As far as I remember, this can be done by editing binding.gyp)
In any case, what I want to do should work in windows.
Maybe nothing should compile because of bugs and is this the norm?
If someone wants to help solve the problem with their own hands, I can provide access (teamviewer) to this virtual machine.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
Yuri Puzynya, 2015-05-17
@3y3

Regarding the working environment:
I would recommend leaving Win XP at least for Win 7. From personal experience - if you suddenly have a problem installing a module on Win XP, no one will even bother to help you with debugging.
I would also recommend Visual Studio 2010 or 2013. In most cases, there will be no difference here. After choosing the version to use, I advise you to register npm config set msvs_version 2013(or 2010, respectively)
It is worth reading the recommendations given in the instructions for working with node-gyp
Installing native modules in iojs is another story. The chance that they will be compiled as submodules of some project is zero, since node-gyp cannot compile under iojs, because it does not know where to download its sources from. Therefore, you will most likely have to install these modules separately, compile them, and then throw them into the project folder.
To compile, use npm install -g pan-gyp. It's a fork of node-gyp specifically for compiling under iojs. Actually, to compile the module:
1. take it from the github
2. in package.jsonthe section we scriptsprescribe preinstall: pan-gyp rebuild. (In the case of the module with which you are suffering, we overwrite the install script immediately)
3. From the module directory, runnpm install .
Some native modules do have compiled binaries, but that is entirely the responsibility of the module developer. And the responsibility is not small either. In the case of your module, there are no such binaries. Most often, if there are binaries, the module will have node-pre-gyp. (Examples v8-profiler , v8-debug ).
By the way, for the examples given, you don't have to overwrite anything at all.
These two modules are sub-modules of node-inspector and install without problems in most cases.
In conclusion:
If you do not want to startle when native modules appear in the project dependencies, then I advise you to really use nodejs, since compilation under iojs is still very unstable in terms of tools.
The module you're struggling with most likely hasn't been tested for iojs at all.
Also pay attention to the package.json engine in this project.

S
stepenno, 2016-11-17
@stepenno

Constantly suffered with this problem on Windows. The global installation of the windows-build-tools module helped:
https://github.com/felixrieseberg/windows-build-tools

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question