Skip to content

Feat/Fix: Deno compatibility (avoid nested npm run in package.json scripts) #41

@abdotop

Description

@abdotop

Description

When installing chdb in a Deno project (using Deno's native npm integration with allowScripts), the installation fails with errors like:
error: Task libchdb not found or error: Task build not found.

Why does this happen?

Deno has a built-in task runner that intercepts npm run commands inside package lifecycles, attempting to map them to deno task in the root deno.json.

Since chdb-node's "install" and "build" scripts rely on nested npm run invocations, Deno intercepts them, fails to find those tasks at the project root, and aborts the installation.

Current Problematic Scripts

In package.json:

"scripts": {
  "install": "npm run libchdb && npm run build",
  "libchdb": "bash ./update_libchdb.sh",
  "fixloaderpath": "bash ./fix_loader_path.sh",
  "build": "node-gyp configure build --verbose && npm run fixloaderpath"
}

Proposed Solution

We can bypass Deno's task interception entirely by invoking the underlying shell scripts and tools (bash and node-gyp) directly, rather than nesting them through npm run. This fix is simple, has zero dependencies, and remains 100% backward-compatible with Node.js/npm.

Proposed changes in package.json:

"scripts": {
  "install": "bash ./update_libchdb.sh && node-gyp configure build --verbose && bash ./fix_loader_path.sh",
  "test": "mocha test_basic.js test_connection.js --timeout 15000",
  "libchdb": "bash ./update_libchdb.sh",
  "fixloaderpath": "bash ./fix_loader_path.sh",
  "build": "node-gyp configure build --verbose && bash ./fix_loader_path.sh"
}

Benefits

  1. Enables seamless, native compatibility with Deno's package manager and deno compile.
  2. Fully preserves existing Node.js and npm behaviors.
  3. No code changes required, only minor adjustments in package.json.

I would be happy to submit a Pull Request (PR) with these changes if you are open to it!

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