Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Windows runtime: process.binding('contextify') Error: No such module #4

Closed
nhandl3 opened this issue Sep 23, 2014 · 6 comments
Closed

Comments

@nhandl3
Copy link

nhandl3 commented Sep 23, 2014

I tried to build this embedded node with vcbuild nosign
All build ok, node --version shows v0.11.13
But when run node alone or with js file it returns follow error:

d:\toollib\atom-editor\atom-shell\vendor\node\Release>node server.js
node.js:738
  var ContextifyScript = process.binding('contextify').ContextifyScript;
                                 ^
Error: No such module
    at Error (native)
    at node.js:738:34

d:\toollib\atom-editor\atom-shell\vendor\node\Release>

I have google but seem no clear clues.
Still investigating...

@zombiezen
Copy link

For others who have hit this issue while trying to build Node.js in non-standard ways, the problem is that all of Node.js's built-in modules are initialized using the __attribute__((constructor)) (on Unix) or dllexport (on Windows). If you're building statically, these get stripped.

The workaround that I used was to modify the NODE_C_CTOR macro to have external linkage and call the module constructors from main. It's a pain, but it gets things moving.

@irbull
Copy link

irbull commented Jun 24, 2016

@zombiezen Do you have a link to what you changed? I'm up against this exact issue. Thanks so much!

@zombiezen
Copy link

I don't have a link, but it's a rather straightforward change:

// node.h
#define NODE_C_CTOR(fn) void fn(void)

// node_main.cc
extern "C" {
  void _register_async_wrap(void);
  // etc...
}

int main(int argc, char *argv[]) {
  _register_async_wrap();
  // etc...
}

@irbull
Copy link

irbull commented Jul 20, 2016

@zombiezen Thank-you so much. I was trying to call the Initialize method on each modules, which often has different syntax for each module. You're solution was exactly what I needed and I doubt I would have figured that out without you. eclipsesource/J2V8@5dd9c0a

If I ever meet you, a drink is certainly on me.

Thanks again!

@tommyZZM
Copy link

tommyZZM commented Oct 6, 2017

for others who wants to embed node as static library have hit this issue,
could also see this issue: JaneaSystems/nodejs-mobile#9

also reference this nodejs pull request nodejs/node#14986.

codebytere pushed a commit that referenced this issue Dec 12, 2017
Currently when running the test without an internet connection there are
two JavaScript test failures and one cctest. The cctest only fails on
Mac as far as I know. (I've only tested using Mac and Linux thus far).

This commit moves the two JavaScript tests to test/internet.

The details for test_inspector_socket_server.cc:

[ RUN      ] InspectorSocketServerTest.FailsToBindToNodejsHost
make[1]: *** [cctest] Segmentation fault: 11
make: *** [test] Error 2

lldb output:

[ RUN      ] InspectorSocketServerTest.FailsToBindToNodejsHost
Process 63058 stopped
* thread #1: tid = 0x7b175, 0x00007fff96d04384
* libsystem_info.dylib`_gai_simple + 87, queue =
* 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
* address=0x0)
    frame #0: 0x00007fff96d04384 libsystem_info.dylib`_gai_simple + 87
libsystem_info.dylib`_gai_simple:
->  0x7fff96d04384 <+87>: movw   (%rdx), %ax
    0x7fff96d04387 <+90>: movw   %ax, -0x2a(%rbp)
    0x7fff96d0438b <+94>: movq   %r13, -0x38(%rbp)
    0x7fff96d0438f <+98>: movq   0x18(%rbp), %rcx

(lldb) bt
* thread #1: tid = 0x7b175, 0x00007fff96d04384
* libsystem_info.dylib`_gai_simple + 87, queue =
* 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1,
* address=0x0)
  * frame #0: 0x00007fff96d04384 libsystem_info.dylib`_gai_simple + 87
    frame #1: 0x00007fff96cfe98b libsystem_info.dylib`search_addrinfo +
179
    frame #2: 0x00007fff96cfafef libsystem_info.dylib`si_addrinfo + 2255
    frame #3: 0x00007fff96cfa67b libsystem_info.dylib`getaddrinfo + 179
    frame #4: 0x00000001017d8888
cctest`uv__getaddrinfo_work(w=0x00007fff5fbfe210) + 72 at
getaddrinfo.c:102
    frame #5: 0x00000001017d880e
cctest`uv_getaddrinfo(loop=0x000000010287cb80, req=0x00007fff5fbfe1c8,
cb=0x0000000000000000, hostname="nodejs.org", service="0",
hints=0x00007fff5fbfe268) + 734 at getaddrinfo.c:192
    frame #6: 0x000000010171f781
cctest`node::inspector::InspectorSocketServer::Start(this=0x00007fff5fbfe658)
+ 801 at inspector_socket_server.cc:398
    frame #7: 0x00000001016ed590
cctest`InspectorSocketServerTest_FailsToBindToNodejsHost_Test::TestBody(this=0x0000000105001fd0)
+ 288 at test_inspector_socket_server.cc:593

I'm not sure about the exact cause for this but when using a standalone
c program to simulate this it seems like when the ai_flags
`AI_NUMERICSERV` is set, which is done in inspector_socket_server.cc
line 394, the servname (the port in the FailsToBindToNodejsHost test) is
expected to be a numeric port string to avoid looking it up in
/etc/services. When the port is 0 as is it was before this commit the
segment fault occurs but not if it is non-zero.

PR-URL: nodejs/node#16255
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@MarshallOfSound
Copy link
Member

This issue is very old and does not directly pertain to any issue with electron's embedding of node, gonna close it out 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants