Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report 'no such built-in module' when load addon file #109

Open
kerwenzhang opened this issue Oct 22, 2024 · 3 comments
Open

Report 'no such built-in module' when load addon file #109

kerwenzhang opened this issue Oct 22, 2024 · 3 comments

Comments

@kerwenzhang
Copy link

I created a simple demo hello.node

#define NAPI_VERSION 3
#define NAPI_CPP_EXCEPTIONS
#include <napi.h>

Napi::String Method(const Napi::CallbackInfo& info) {
  Napi::Env env = info.Env();
  return Napi::String::New(env, "world from addon");
}

Napi::Object Init(Napi::Env env, Napi::Object exports) {
  exports.Set(Napi::String::New(env, "hello"),
              Napi::Function::New(env, Method, "hello"));
  return exports;
}

NODE_API_MODULE(hello, Init)

And call it in node.js express project

app.js
app.use('/hello', function(req, res) {
    const modulePath = path.join(__dirname, 'hello.node');
    const addon = require(modulePath);

    res.send(addon.hello()); // 'world'
});

Run express project directly(node app.js), the addon file could be loaded successfully. But after I package it to exe using Node SEA, it begin to report below error during run exe.
image

@nodejs/single-executable
Does that mean Node SEA bootstrap not support to load addon file? Does Node SEA have a plan to support .node file? What's the latest progress?

@GabenGar
Copy link

Does it work without express (which is in fact not a built-in module)?

@kerwenzhang
Copy link
Author

@GabenGar I removed express, call addon in app.js directly. Still report No such built-in module error.

const path = require('path');

const modulePath = path.join(__dirname, 'hello.node');
const addon = require(modulePath);

console.log(addon.hello()); 

@Stefanieissun
Copy link

waiting for answer

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

No branches or pull requests

3 participants