oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
72.83k stars 2.64k forks source link

"Cannot find module" DuckDb #6541

Open nshiab opened 10 months ago

nshiab commented 10 months ago

What version of Bun is running?

1.0.6+969da088f5db3258a803ec186012e30f992829b4

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

In a new repo, run bun init and then bun add duckdb (version 0.9.1 is the latest right now).

In index.ts, add this:

import { Database } from "duckdb";
const db = new Database(":memory:");

Run bun index.ts.

What is the expected behavior?

When used with NodeJS, there is no error, and we can use DuckDB.

What do you see instead?

It will give you this error: Cannot find module "/node_modules/duckdb/lib/binding/duckdb.node" from "node_modules/duckdb/lib/duckdb-binding.js"

Additional information

Thank you for your amazing work! :)

Electroid commented 10 months ago

Duplicate of #4959

Jarred-Sumner commented 8 months ago

Fixed by @dylan-conway and @paperdave in #7132

This will be part of the Bun v1.0.17 release, which ships in a few hours from the time of writing.

In the meantime, you can run bun upgrade --canary

pcc-huangm commented 5 months ago

This is still an issue for me.

docker run -it oven/bun --entrypoint bash root@68423ffc1cc0:/home/bun/app# bun -v 1.0.31

root@68423ffc1cc0:/home/bun/app# bun index.ts error: Cannot find module "/root/.bun/install/cache/duckdb@0.10.0/lib/binding/duckdb.node" from "/root/.bun/install/cache/duckdb@0.10.0/lib/duckdb-binding.js"

-- sample code index.ts

var duckdb = require('duckdb'); var db = new duckdb.Database(':memory:'); // or a file name for a persistent DB db.all('SELECT 42 AS fortytwo', function(err, res) { if (err) { console.warn(err); return; } console.log(res[0].fortytwo) });