Wrangler compatibility issues
Cannot use nuxtHub database when initializing a new project with the hello-edge template or by following the Add to Nuxt project instruction.
Steps to reproduce the behavior:
- Initialize new project by running
npx nuxthub init my-app - run
cd my-app - run
pnpm dev - errors
- Failed to initialize wrangler bindings proxy write EPIPE
- [unhandledRejection] Missing Cloudflare DB binding (D1)
Expected behavior No errors
Steps taken to remove error Downgrade wrangler devDependency to 3.104. Any version past this will result in the previously mentioned error
- run
pnpm add [email protected] - run
pnpm dev - no error
Getting the same Missing Cloudflare DB binding (D1) issue here with a brand new install, although it only happens when doing npx nuxt build && npx nuxthub preview – running in the usual dev works fine.
Downgrading my wrangler version to 3.104 doesn't fix it either
Do you use linux? Can you provide the output of npx nuxi info?
Missing Cloudflare bindings in local machine, means that worked couldn't simulate worker environment in your machine.
@zacwebb Do you have same issue with NuxtHub starter? npx nuxthub init my-app
Do you use linux? Can you provide the output of
npx nuxi info?
Nah MacOS Sequoia. Here's my nuxi info ouptut @farnabaz:
------------------------------
- Operating System: Darwin
- Node Version: v24.0.2
- Nuxt Version: 3.17.5
- CLI Version: 3.25.1
- Nitro Version: 2.11.12
- Package Manager: [email protected]
- Builder: -
- User Config: modules, devtools, runtimeConfig, future, compatibilityDate, hub, eslint
- Runtime Modules: @nuxthub/[email protected], @nuxt/[email protected]
- Build Modules: -
------------------------------
@zacwebb Do you have same issue with NuxtHub starter?
npx nuxthub init my-app
Yep same issue, I tried:
- Fresh install with
npx nuxthub init my-app - Update
nuxt.config.jsto havehub.database = true - Add a D1 call in the server, e.g. in
server/api/ping.tsadd:
export default eventHandler(async () => {
// Example query from https://hub.nuxt.com/docs/features/database#prepare
const result = await hubDatabase().exec(`CREATE TABLE IF NOT EXISTS frameworks (id INTEGER PRIMARY KEY, name TEXT NOT NULL, year INTEGER NOT NULL DEFAULT 0)`)
console.log(result)
return 'pong'
})
- Run
npx nuxt build && npx nuxthub preview - Navigate to
http://localhost:[port]/api/pingand see Missing Cloudflare DB binding (D1)
@zacwebb This is expected behavior in built version. When you build the project, module does not provide local fallback for bindings (including database) and therefore you can't run built version in your local machine.
Try publishing the build to Cloudflare and it will work as expected.