Open vanpipy opened 2 years ago
I get a completely different error on latest main
:
Download https://registry.npmjs.org/is-core-module
Download https://registry.npmjs.org/has
Download https://registry.npmjs.org/function-bind
Download https://registry.npmjs.org/has/-/has-1.0.3.tgz
Download https://registry.npmjs.org/ms/-/ms-2.1.2.tgz
Download https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz
Download https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.5.0.tgz
Download https://registry.npmjs.org/commander/-/commander-9.4.0.tgz
Download https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz
Download https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz
Download https://registry.npmjs.org/tarn/-/tarn-3.0.2.tgz
Download https://registry.npmjs.org/getopts/-/getopts-2.3.0.tgz
Download https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz
Download https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz
Download https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz
Download https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz
Download https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz
Download https://registry.npmjs.org/knex/-/knex-2.3.0.tgz
Download https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
Download https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz
Download https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz
Download https://registry.npmjs.org/tildify/-/tildify-2.0.0.tgz
Download https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz
Download https://registry.npmjs.org/debug/-/debug-4.3.4.tgz
Download https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz
Knex: run
$ npm install better-sqlite3 --save
Cannot find module 'better-sqlite3'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/internal/config-resolver.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/Knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
Error: Cannot find module 'better-sqlite3'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/internal/config-resolver.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/Knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
at Function.Module._resolveFilename (deno:ext/node/02_require.js:609:17)
at Function.Module._load (deno:ext/node/02_require.js:441:29)
at Module.require (deno:ext/node/02_require.js:652:21)
at require (deno:ext/node/02_require.js:782:18)
at Client_BetterSQLite3._driver (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js:7:12)
at Client_BetterSQLite3.initializeDriver (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/client.js:190:26)
at new Client (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/client.js:75:12)
at new Client_SQLite3 (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/sqlite3/index.js:22:5)
at new Client_BetterSQLite3 (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js:5:1)
at knex (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/Knex.js:16:28)
error: Uncaught Error: Knex: run
$ npm install better-sqlite3 --save
Cannot find module 'better-sqlite3'
Require stack:
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/internal/config-resolver.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/Knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/index.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
- /Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/knex.js
at Client_BetterSQLite3.initializeDriver (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/client.js:194:13)
at new Client (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/client.js:75:12)
at new Client_SQLite3 (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/sqlite3/index.js:22:5)
at new Client_BetterSQLite3 (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/dialects/better-sqlite3/index.js:5:1)
at knex (file:///Users/ib/Library/Caches/deno/npm/registry.npmjs.org/knex/2.3.0/lib/knex-builder/Knex.js:16:28)
at file:///Users/ib/dev/deno/foo.js:3:12
I assume the root cause has already been fixed and will be released in v1.25.1 tonight, but we need need to address problem with sqlite
That is great! Thanks for your work a lot!
If I add import "npm:better-sqlite3";
at the top of the script, I see further different error.
$ deno run -A --unstable a.js
sqlite does not support inserting default values. Set the `useNullAsDefault` flag to hide this warning. (see docs https://knexjs.org/guide/query-builder.html#insert).
Error: Could not locate the bindings file. Tried:
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/better_sqlite3.node
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/Debug/better_sqlite3.node
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/Release/better_sqlite3.node
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/out/Debug/better_sqlite3.node
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/Debug/better_sqlite3.node
→ /Users/kt3k/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/out/Release/better_sqlite3.node
...
better-sqlite3
seems depending on Node API. I think this issue is blocked by #13633
Just tried with https://github.com/denoland/deno/pull/13633 and it appears to resolve this issue.
I just tried this with deno 1.29.4 and it does not appear to be resolved.
import Database from 'npm:better-sqlite3'
const db = new Database(':memory:')
deno run --unstable -A repro.ts
error: Uncaught Error: Could not locate the bindings file. Tried:
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/out/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/out/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/build/default/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/compiled/18.12.1/darwin/arm64/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/addon-build/release/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/addon-build/debug/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/addon-build/default/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/lib/binding/node-v108-darwin-arm64/better_sqlite3.node
at bindings (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/bindings.js:126:9)
at new Database (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/8.0.1/lib/database.js:48:64)
at file:///Users/andrew/Code/scratchwork/deno.ts:3:12
I have tried this on both an M1 mac and linux. Listing the files inside that bindings folder, I see this:
ls -l /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/
-rw-r--r-- 1 andrew staff 1.1K Oct 26 1985 LICENSE.md
-rw-r--r-- 1 andrew staff 3.4K Oct 26 1985 README.md
-rw-r--r-- 1 andrew staff 5.9K Oct 26 1985 bindings.js
-rw-r--r-- 1 andrew staff 660 Oct 26 1985 package.json
Just another update (mostly to keep the git bot from marking this stale 😅). This appears to still be broken in deno 1.30.0
adding another to the mix, an asynchronous sqlite library https://www.npmjs.com/package/sqlite3 (which the readme specifies uses node-pre-gyp to download prebuilt binaries)
error: Uncaught Error: Cannot find module '/Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/binding/napi-v6-darwin-unknown-arm64/node_sqlite3.node'
Require stack:
- /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/sqlite3-binding.js
- /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/sqlite3.js
- /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/sqlite3.js
at Function.Module._resolveFilename (deno:ext/node/02_require.js:637:17)
at Function.Module._load (deno:ext/node/02_require.js:469:29)
at Module.require (deno:ext/node/02_require.js:680:21)
at require (deno:ext/node/02_require.js:820:18)
at Object.<anonymous> (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/sqlite3-binding.js:4:17)
at Object.<anonymous> (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/sqlite3-binding.js:7:4)
at Module._compile (deno:ext/node/02_require.js:747:36)
at Object.Module._extensions..js (deno:ext/node/02_require.js:780:12)
at Module.load (deno:ext/node/02_require.js:658:34)
at Function.Module._load (deno:ext/node/02_require.js:515:14)
I dont personally need this library for any projects, but I discovered this while attempting to compile a few benchmarks. Similarly, the folder which it expects to contain the binary is empty:
l /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/sqlite3/5.1.4/lib/
total 24K
-rw-r--r-- 1 andrew.kaiser staff 241 Oct 26 1985 sqlite3-binding.js
-rw-r--r-- 1 andrew.kaiser staff 7.0K Oct 26 1985 sqlite3.d.ts
-rw-r--r-- 1 andrew.kaiser staff 6.3K Oct 26 1985 sqlite3.js
-rw-r--r-- 1 andrew.kaiser staff 1.4K Oct 26 1985 trace.js
this still appears to be broken in deno v1.31. Adding this comment because the 1.31 blog post points out a stabilization of the Node-API, which better-sqlite3 seems to be built off of https://deno.com/blog/v1.31#stabilization-of-node-api. I think this is perhaps because deno attempts to download only the files that are part of the dependency tree, or defined in the package.json file. On the other hand, I believe npm just downloads everything in the published tarball. This is the contents of the package.json
{
"name": "bindings",
"description": "Helper module for loading your native module's .node file",
"keywords": [
"native",
"addon",
"bindings",
"gyp",
"waf",
"c",
"c++"
],
"version": "1.5.0",
"author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",
"repository": {
"type": "git",
"url": "git://github.com/TooTallNate/node-bindings.git"
},
"main": "./bindings.js",
"bugs": {
"url": "https://github.com/TooTallNate/node-bindings/issues"
},
"homepage": "https://github.com/TooTallNate/node-bindings",
"license": "MIT",
"dependencies": {
"file-uri-to-path": "1.0.0"
}
}
ls -l /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/
-rw-r--r-- 1 andrew staff 1.1K Oct 26 1985 LICENSE.md
-rw-r--r-- 1 andrew staff 3.4K Oct 26 1985 README.md
-rw-r--r-- 1 andrew staff 5.9K Oct 26 1985 bindings.js
-rw-r--r-- 1 andrew staff 660 Oct 26 1985 package.json
another native library failed. This one is https://github.com/cocktailpeanut/dalai (https://www.npmjs.com/package/dalai), which was a recent share on HN that runs facebook's llama.cpp language model natively. The error is below:
deno run npm:dalai llama
innerError Error: Cannot find module '../build/Debug/pty.node'
Require stack:
- /home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/index.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/dalai/0.1.0/index.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/dalai/0.1.0/bin/cli.js
at Function.Module._resolveFilename (ext:deno_node_loading/02_require.js:635:15)
at Function.Module._load (ext:deno_node_loading/02_require.js:467:27)
at Module.require (ext:deno_node_loading/02_require.js:678:19)
at require (ext:deno_node_loading/02_require.js:818:16)
at Object.<anonymous> (file:///home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js:30:15)
at Object.<anonymous> (file:///home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js:278:4)
at Module._compile (ext:deno_node_loading/02_require.js:745:34)
at Object.Module._extensions..js (ext:deno_node_loading/02_require.js:778:10)
at Module.load (ext:deno_node_loading/02_require.js:656:32)
at Function.Module._load (ext:deno_node_loading/02_require.js:513:12)
error: Uncaught Error: Cannot find module '../build/Release/pty.node'
Require stack:
- /home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/index.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/dalai/0.1.0/index.js
- /home/andrew/.cache/deno/npm/registry.npmjs.org/dalai/0.1.0/bin/cli.js
at Function.Module._resolveFilename (ext:deno_node_loading/02_require.js:635:15)
at Function.Module._load (ext:deno_node_loading/02_require.js:467:27)
at Module.require (ext:deno_node_loading/02_require.js:678:19)
at require (ext:deno_node_loading/02_require.js:818:16)
at Object.<anonymous> (file:///home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js:26:11)
at Object.<anonymous> (file:///home/andrew/.cache/deno/npm/registry.npmjs.org/node-pty/0.10.1/lib/unixTerminal.js:278:4)
at Module._compile (ext:deno_node_loading/02_require.js:745:34)
at Object.Module._extensions..js (ext:deno_node_loading/02_require.js:778:10)
at Module.load (ext:deno_node_loading/02_require.js:656:32)
at Function.Module._load (ext:deno_node_loading/02_require.js:513:12)
deno --version
deno 1.31.2 (release, x86_64-unknown-linux-gnu)
v8 11.0.226.19
typescript 4.9.4
tested on linux, also npx dalai llama
does succeed
@kt3k
better-sqlite3
seems depending on Node API. I think this issue is blocked by #13633
I think it is blocked by https://github.com/denoland/deno/issues/19130
Expect to search under /home/vscode/.cache/deno/npm/private-npm/napi-example/1.0.0
.
But actually search under /home/vscode/.cache/deno/npm/private-npm/bindings/1.5.0
This is still a problem in deno 1.36.4
. It appears that Bun 1.0 now supports better-sqlite3
https://github.com/WiseLibs/better-sqlite3/issues/1034#issuecomment-1712805135
We are moving to bun 1.0, it appears to work
It looks to me like this is still a problem in deno 1.44.2
hmm so I see the pr that closed this issue was part of the 1.45.5 release (sidenote: I found by poking around the Releases on github, it would be ideal if I could link my way from an issue/pr to the deno release that it arrived in. Weirdly, I can see this pr merged as this commit into main here but it doesnt reference where it appears in the 1.45.5 tag commits here
This does not appear to be fixed though on macos.
deno 1.45.5 (release, aarch64-apple-darwin)
v8 12.7.224.13
typescript 5.5.2
This snippet:
import * as sqlite from 'npm:better-sqlite3@11.1.2'
const database = new sqlite.default(':memory:')
gives the following output:
Uncaught Error: Could not locate the bindings file. Tried:
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/build/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/build/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/build/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/out/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/Debug/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/out/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/Release/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/build/default/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/compiled/20.11.1/darwin/arm64/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/addon-build/release/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/addon-build/debug/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/addon-build/default/install-root/better_sqlite3.node
→ /Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/lib/binding/node-v108-darwin-arm64/better_sqlite3.node
at bindings (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/bindings/1.5.0/bindings.js:126:9)
at new Database (file:///Users/andrew/Library/Caches/deno/npm/registry.npmjs.org/better-sqlite3/11.1.2/lib/database.js:48:64)
at <anonymous>:1:39
Env
Phenomenon
Run the code:
And throw exception:
Then find the keyword in the
tarn
package:Expected
Resolve the node dependencies.