question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. Itย collects links to all the places you might be looking at while hunting down a tough bug.

And, if youโ€™re still stuck at the end, weโ€™re happy to hop on a call to see how we can help out.

๐Ÿ› BUG: Unable to use D1 binding with local pages dev

See original GitHub issue

What version of Wrangler are you using?

0.0.0-8fac577c (npx wrangler@d1 --version)

What operating system are you using?

Windows

Describe the Bug

When attempting to use D1 locally for Pages function following the docs I get the following error

F:\git\workers\car-api [D1 +6 ~5 -4 !]> npx wrangler@d1 pages dev .\public\ --d1=DB
๐Ÿšง 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
Compiling worker to "C:\Users\Jake\AppData\Local\Temp\functionsWorker-0.30216710979718786.js"...
Compiled Worker successfully.
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎโ”‚ [b] open a browser, [d] open Devtools, [c] clear console, [x] to exit                                                                                                                             โ”‚โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏDebugger listening on ws://localhost:9229/58d15b5f-751b-4df9-b4b6-8e50da2732a6
Debugger listening on ws://localhost:9229/58d15b5f-751b-4df9-b4b6-8e50da2732a6
For help, see: https://nodejs.org/en/docs/inspector
[pages:wrn] Service bindings are experimental. There may be breaking changes in the future.
[NPXI] better-sqlite3 not available locally. Attempting to use npx to install temporarily.
[pages:inf] Updated `Request.cf` object cache!
[NPXI] Installing... (npx -y -p better-sqlite3@^7.5.3)
[pages:err] Error: npx-import failed for better-sqlite3 with message:
    Failed to find temporary install directory. Looking for paths matching '/.npm/_npx/' in:
[""]

You should install better-sqlite3 locally:
    npm install --save-dev better-sqlite3@^7.5.3


    at npxImport (F:\git\workers\car-api\node_modules\node_modules\npx-import\lib\index.js:31:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at MemoryStorage.getSqliteDatabase (F:\git\workers\car-api\node_modules\@miniflare\storage-memory\src\local.ts:124:33)
    at BetaDatabase.init (F:\git\workers\car-api\node_modules\@miniflare\d1\src\database.ts:140:16)
    at D1Plugin.getBetaDatabase (F:\git\workers\car-api\node_modules\@miniflare\d1\src\plugin.ts:50:5)
    at D1Plugin.setup (F:\git\workers\car-api\node_modules\@miniflare\d1\src\plugin.ts:58:28)
    at EventTarget.#runSetup (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:320:20)
    at EventTarget.#init (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:452:7)
    at EventTarget.getPlugins (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:985:5

After installing and retrying the command, I get a new error (npxImport)

 F:\git\workers\car-api [D1 +6 ~5 -4 !]> npx wrangler@d1 pages dev .\public\ --d1=DB 
๐Ÿšง 'wrangler pages <command>' is a beta command. Please report any issues to https://github.com/cloudflare/wrangler2/issues/new/choose
Compiling worker to "C:\Users\Jake\AppData\Local\Temp\functionsWorker-0.622393753708625.js"...
Compiled Worker successfully.
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎโ”‚ [b] open a browser, [d] open Devtools, [c] clear console, [x] to exit                                                                                                                             โ”‚โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏDebugger listening on ws://localhost:9229/5b5fd145-7ae5-44d9-9702-6be85fe17644
Debugger listening on ws://localhost:9229/5b5fd145-7ae5-44d9-9702-6be85fe17644
For help, see: https://nodejs.org/en/docs/inspector
[pages:wrn] Service bindings are experimental. There may be breaking changes in the future.
[pages:err] Error: You must call npxImport for a package before calling npxResolve. Got: better-sqlite3
    at npxResolve (F:\git\workers\car-api\node_modules\node_modules\npx-import\lib\index.js:48:15)
    at MemoryStorage.getSqliteDatabase (F:\git\workers\car-api\node_modules\@miniflare\storage-memory\src\local.ts:129:9)
    at BetaDatabase.init (F:\git\workers\car-api\node_modules\@miniflare\d1\src\database.ts:140:16)
    at D1Plugin.getBetaDatabase (F:\git\workers\car-api\node_modules\@miniflare\d1\src\plugin.ts:50:5)
    at D1Plugin.setup (F:\git\workers\car-api\node_modules\@miniflare\d1\src\plugin.ts:58:28)
    at EventTarget.#runSetup (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:320:20)
    at EventTarget.#init (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:452:7)
    at EventTarget.getPlugins (F:\git\workers\car-api\node_modules\@miniflare\core\src\index.ts:985:5)
    at createServer (F:\git\workers\car-api\node_modules\@miniflare\http-server\src\index.ts:355:19)
    at startServer (F:\git\workers\car-api\node_modules\@miniflare\http-server\src\index.ts:456:18)
[pages:inf] Updated `Request.cf` object cache!

For Windows, wrangler@d1 seems to be broken entirely. If I run npx wrangler@d1 pages dev .\public\ I get the same out as the first error (without better-sqlite3 installed). I tested with Linux using a dev container in VS Code and it appears that it will always fail when better-sqlite3 is installed via NPM. If I use npx wrangler@d1 pages dev public/ --d1=DB then it works in the container, but if I install better-sqlite3 then the command fails with the npxImport error.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
geelencommented, Aug 9, 2022

@Cyb3r-Jak3 I think the first error is actually related to https://github.com/geelen/npx-import not being tested on windows yet. Iโ€™ve raised https://github.com/geelen/npx-import/issues/5 to track it. But it sounds like the second case, when you install better-sqlite3 locally, is now fixedโ€ฆ

0reactions
WalshyDevcommented, Oct 19, 2022

Hey,

This should now be resolved, let us know if it is not!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Partitions encrypted in Kickstart fails to be unlocked by Clevis ...
Description of problem: Automatic unlock of partitions using clevis tpm pin does not work on RHEL Edge 8.3 The following kickstartย ...
Read more >
D1 - Binding of Isaac: Rebirth Wiki - Fandom
D1 is an unlockable activated item added in The Binding of Isaac: Afterbirth โ€ . Duplicates 1 random pickup in the current room, including...
Read more >
D1: our quest to simplify databases - The Cloudflare Blog
When running wrangler dev -โ€“local -โ€“persist , an SQLite file will be created inside .wrangler/state . You can then use a local GUI...
Read more >
Troubleshoot domain and TLS/SSL certificates - Azure App ...
This problem might happen if you have multiple IP-based TLS/SSL bindings for the same IP address across multiple apps. For example, app A...
Read more >
(The only proper) PDO tutorial - Treating PHP Delusions
It is very important to understand which query parts you can bind using ... Although there are several error handling modes in PDO,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found