Skip to content

Native modules without bindings.gyp #53

Description

@konsumer

Hi, great & useful package.

I work on node-raylib and I am trying to help users make standalone games with it. I am not sure how to inline the native dep. It doesn't use bindings.gyp (node-raylib uses cmakejs.) Is it possible?

I might just be misunderstanding how addons works, I am not sure.

This works fine:

boxednode -s main.js -t hello

and produces hello which requires node_modules/raylib/build/Release/node-raylib.node in same dir to work. I'd like to inline it, for a single executable file (with no separate native module needed) so I tried this:

compileJSFileAsBinary({
  nodeVersionRange: process.versions.node,
  sourceFile: 'main.js',
  targetFile: 'hello'
  addons: [
    {
      path: 'node_modules/raylib',
      requireRegexp: /build\/Release\/node-raylib\.node/
    }
  ]
})

And I get this:

→  Preparing addon at node_modules/raylib ...
  ✖  Failed: Cannot read /var/folders/47/smf4dj454fd4mw881t380dz80000gs/T/boxednode/main/node-v20.0.0/deps/9752c49f4d546974ac7d079cc418da10/binding.gyp: ENOENT: no such file or directory, open '/var/folders/47/smf4dj454fd4mw881t380dz80000gs/T/boxednode/main/node-v20.0.0/deps/9752c49f4d546974ac7d079cc418da10/binding.gyp'
/Users/konsumer/Desktop/testbuild/node_modules/boxednode/lib/native-addons.js:18
        throw new Error(`Cannot read ${filename}: ${err.message}`);

Error: Cannot read /var/folders/47/smf4dj454fd4mw881t380dz80000gs/T/boxednode/main/node-v20.0.0/deps/9752c49f4d546974ac7d079cc418da10/binding.gyp: ENOENT: no such file or directory, open '/var/folders/47/smf4dj454fd4mw881t380dz80000gs/T/boxednode/main/node-v20.0.0/deps/9752c49f4d546974ac7d079cc418da10/binding.gyp'
    at loadGYPConfig (/Users/konsumer/Desktop/testbuild/node_modules/boxednode/lib/native-addons.js:18:15)
    at async modifyAddonGyp (/Users/konsumer/Desktop/testbuild/node_modules/boxednode/lib/native-addons.js:96:20)
    at async compileJSFileAsBinaryImpl (/Users/konsumer/Desktop/testbuild/node_modules/boxednode/lib/index.js:246:33)
    at async compileJSFileAsBinary (/Users/konsumer/Desktop/testbuild/node_modules/boxednode/lib/index.js:371:9)

Node.js v20.0.0

/var/folders/47/smf4dj454fd4mw881t380dz80000gs/T/boxednode/main/node-v20.0.0/deps/9752c49f4d546974ac7d079cc418da10 seems to point to raylib, so I guess the error is essentially saying "node-raylib does not use bindings.gyp" which is true:

bin/
build/
drm/
man/
node_modules/
src/
tools/
CMakeLists.txt
LICENSE.md
README.md
index.js
package-lock.json
package.json

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions