Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Deno #439

Open
drewbitt opened this issue Apr 23, 2024 · 8 comments
Open

Not working with Deno #439

drewbitt opened this issue Apr 23, 2024 · 8 comments

Comments

@drewbitt
Copy link

drewbitt commented Apr 23, 2024

Loosely related to #430 as well

import { SimpleNodeDB } from "npm:simple-data-analysis";

const sdb = new SimpleNodeDB();

deno run -A filename.ts

error: Uncaught (in promise) Error: Cannot find module '/Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/binding/duckdb.node'
Require stack:
- /Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/duckdb-binding.js
- /Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/duckdb.js
- /Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/duckdb.js
    at Function.Module._resolveFilename (node:module:566:15)
    at Function.Module._load (node:module:453:27)
    at Module.require (node:module:603:19)
    at require (node:module:709:16)
    at Object.<anonymous> (file:///Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/duckdb-binding.js:4:15)
    at Object.<anonymous> (file:///Users/drewbitt/Repos/x/scripts/find-cadences-imports/node_modules/.deno/[email protected]/node_modules/duckdb/lib/duckdb-binding.js:7:4)
    at Module._compile (node:module:653:34)
    at Object.Module._extensions..js (node:module:667:10)
    at Module.load (node:module:591:32)
    at Function.Module._load (node:module:486:12)

Possibly fixed if packaged via jsr and it could resolve duckdb in #431 , but the current implementation in https://jsr.io/@nshiab/simple-data-analysis has the same problem.

Summary

It is looking for lib/binding/duckdb.node' but I don't have that

74987
@drewbitt
Copy link
Author

Likely related to denoland/deno#16164. There is a way around it (doing the postinstall manually) in denoland/deno#15611 (comment)

@nshiab
Copy link
Owner

nshiab commented Apr 23, 2024

Thank you @drewbitt! Busy week for me. I'll check this soon. I would love the library to work with Deno, too. I quickly tried publishing on jsr.io (as you found out), but it wasn't a success.

@drewbitt
Copy link
Author

drewbitt commented Jun 13, 2024

You can now run simple-data-analysis in Deno using DENO_FUTURE=1 and installing packages with npm install (until Deno supports postinstall). Simple example:

❯ npm install duckdb simple-data-analysis
npm WARN deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm WARN deprecated @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: Glob versions prior to v9 are no longer supported
npm WARN deprecated [email protected]: This package is no longer supported.
npm WARN deprecated [email protected]: This package is no longer supported.

added 153 packages in 3s

9 packages are looking for funding
  run `npm fund` for details

~/Downloads via  v20.12.2 took 2s
❯ DENO_FUTURE=1 deno
Deno 1.44.2
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> import { SimpleDB } from "npm:simple-data-analysis"; const sdb = new SimpleDB();
undefined
> const employees = sdb.newTable("employees")
undefined
> await employees.logTable()

table employees: no data
undefined

@nshiab
Copy link
Owner

nshiab commented Jun 13, 2024

I just tested the example from the readme and it works well!

Do you know what DENO_FUTURE=1 stands for?

And I asked about the postinstall in this issue: denoland/deno#23656 (comment)

@drewbitt
Copy link
Author

DENO_FUTURE=1 allows it to use node_modules installed by npm install which is currently the only way postinstall could ever run (through npm)

@nshiab
Copy link
Owner

nshiab commented Jun 13, 2024

Hmmmm. I see. Thank you! Why are you interested in simple-data-analysis, if I may ask? 🤓

@drewbitt
Copy link
Author

Seems like a great way of interacting with DuckDB and replace some of our Deno scripts for data analysis and reporting with something more performant with easy to use features.

@nshiab
Copy link
Owner

nshiab commented Jun 13, 2024

Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants