Skip to content

Integration to a CLI application created using PKGΒ #1439

@JosephJibi

Description

@JosephJibi

Question

I'm trying to bundle a Node.js CLI tool that uses @xenova/transformers into a single executable using pkg.

The build works fine, but when I run the packaged executable, I get this error:

Error: Cannot find module '../bin/napi-v3/linux/x64/onnxruntime_binding.node'
Require stack:
- /snapshot/custom-cli/node_modules/onnxruntime-node/dist/binding.js
- /snapshot/custom-cli/node_modules/onnxruntime-node/dist/backend.js
- /snapshot/custom-cli/node_modules/onnxruntime-node/dist/index.js
- /snapshot/custom-cli/dist/custom-cli.cjs

Build command:

webpack && pkg -t node18-linux -o custom-cli dist/custom-cli.cjs

pkg config:

"pkg": {
  "assets": [
    "node_modules/onnxruntime-node/bin/napi-v3/**/onnxruntime_binding.node"
  ]
}

Is it possible to give a custom absolute path for ONNX native bindings (something like this):

import { env } from "@xenova/transformers";
env.backends.onnx.customBindingPath = "/custom-cli/onnxruntime_binding.node";

then the tool could:

  • Extract prebuilt binaries (onnxruntime_binding.node) from a known location (or GitHub ZIP)

  • Pass that custom path to @xenova/transformers / onnxruntime-node

  • Load correctly even when packaged by pkg

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions