Skip to content

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

Description

@kerwenzhang

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?

Activity

  1. GabenGar commented on Oct 22, 2024

    @GabenGar

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

  2. kerwenzhang commented on Oct 23, 2024

    @kerwenzhang
    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()); 
    
  3. Stefanieissun commented on Nov 11, 2024

    @Stefanieissun

    waiting for answer

  4. dustinlacewell commented on Apr 30, 2025

    @dustinlacewell

    Is it possible to some info on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions