Skip to content

Could not locate the bindings file with nuxt cli #3249

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

Open
Rednas83 opened this issue Mar 14, 2025 · 12 comments
Open

Could not locate the bindings file with nuxt cli #3249

Rednas83 opened this issue Mar 14, 2025 · 12 comments

Comments

@Rednas83
Copy link

Environment



Version

v3

Reproduction

npx nuxi@latest init
Image

Description

When running the dev server with pnpm dev there is a missing bindings error with better-sqlite
Image
Tried
Image

Also content.config.ts was missing so It had to be manually added.

import { defineContentConfig, defineCollection } from '@nuxt/content'

export default defineContentConfig({
  collections: {
    content: defineCollection({
      type: 'page',
      source: '**/*.md'
    })
  }
})

Perhaps add a default one to get started easier?

Additional context

No response

Logs

@Rednas83 Rednas83 added the v2 Relevant for @nuxt/content v2 label Mar 14, 2025
@Suv4o
Copy link

Suv4o commented Mar 16, 2025

Any updates on this issue?

@farnabaz
Copy link
Member

I believe you are using pnpm@10. In pnpm@10, there is a breaking/security change that prevents package scripts from being executed. Run pnpm approve-builds and choose better-sqlite3 to allow the execution. (If it didn't work on first time, some times you need to run twice or remove node_modules first)

@farnabaz farnabaz removed the v2 Relevant for @nuxt/content v2 label Mar 17, 2025
@jordyfontoura
Copy link

Issue: Cannot Start Nuxt with @nuxt/content

Steps to reproduce:

  • pnpm: 10.6.2
  • Node.js: v22.14.0
  1. Run pnpm create nuxt@latest
  2. Select the option pnpm
  3. Select the option to install @nuxt/content (The error does not occur without @nuxt/content)
    Image
  4. cd base-project
  5. Run pnpm dev

Error:

ERROR  Cannot start nuxt:  Could not locate the bindings file. Tried: 
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/build/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/build/Debug/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/build/Release/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/out/Debug/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/Debug/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/out/Release/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/Release/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/build/default/better_sqlite3.node
 → /home/base-project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/compiled/22.14.0/linux/x64/better_sqlite3.node
 → /home/project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/addon-build/release/install-root/better_sqlite3.node
 → /home/project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/addon-build/debug/install-root/better_sqlite3.node
 → /home/project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/addon-build/default/install-root/better_sqlite3.node
 → /home/project/node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/lib/binding/node-v127-linux-x64/better_sqlite3.node

    at bindings (node_modules/.pnpm/[email protected]/node_modules/bindings/bindings.js:126:9)
    at new Database (node_modules/.pnpm/[email protected]/node_modules/better-sqlite3/lib/database.js:48:64)
    at getDB (node_modules/.pnpm/[email protected][email protected]/node_modules/db0/dist/connectors/better-sqlite3.mjs:20:11)
    at Object.exec (node_modules/.pnpm/[email protected][email protected]/node_modules/db0/dist/connectors/better-sqlite3.mjs:27:20)
    at getLocalDatabase (node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxt/content/dist/module.mjs:238:12)
    at async processCollectionItems (node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxt/content/dist/module.mjs:2561:14)
    at async node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@nuxt/content/dist/module.mjs:2538:20
    at async initNuxt (node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected][email protected]_25afd27c75b4f9d444feb6bc2ea68daf/node_modules/nuxt/dist/shared/nuxt.DQBGBwNc.mjs:5789:3)
    at async NuxtDevServer._load (node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/cli/dist/chunks/dev2.mjs:161:5)
    at async NuxtDevServer.load (node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/cli/dist/chunks/dev2.mjs:95:7)

@farnabaz
Copy link
Member

@jordyfontoura Try removing node_modules and re-install. sometimes pnpm does not detect packages properly.

@Rednas83
Copy link
Author

Tried deleting node_modules and pnpm install but it didn't help.

For now it's probably easiest to downgrade to pnpm9 and run pnpm install.
package.json
"packageManager": "[email protected]"

Perhaps it could be mentioned in the docs?

@MukurowZ
Copy link

MukurowZ commented Apr 1, 2025

This happens with Bun workspace too. (If not using workspace, it works fine)

  • Bun: 1.1.34
  • Operating System: macOS Sequoia 15.3.2 (24D81)
  • Nuxt Version: 3.16.0

Step to reproduce

  1. Create Bun workspace
  2. Create Package inside workspace using bun create nuxt
  3. Select the option to install @nuxt/content
  4. bun run dev
  5. Error occur as the same.

@2giosangmitom
Copy link

I have the same issue with pnpm v10. Try pnpm approve-builds and select better-sqlite3. This worked for me. Good luck!

@justindefodji
Copy link

For NPM users, switching to the latest node version (22.14.0) fixed the issue!
Any confirmation?

@infabo
Copy link

infabo commented Apr 2, 2025

No, 22.14.0 and npm still broken here.

@farnabaz
Copy link
Member

farnabaz commented Apr 4, 2025

If you are using node 22, try using the experimental SQLite connector.

defineNuxtConfig({
  content: {
    experimental: { nativeSqlite: true }
  }
})

Better Sqlite 3 requires a native binary to operate, and this cause some issues in different environments. Using native sqlite is the futuristic solution that is in experimental mode.

@kingyue737
Copy link

experimental nativeSqlite feature seems not work for me. Nuxt still cannot start without better-sqlite3 binding.

I'm using node v22.11.0 on Windows.

@infabo
Copy link

infabo commented Apr 7, 2025

@farnabaz Thanks, your suggestion for experimental sqlite fixed it for us. See https://content.nuxt.com/docs/getting-started/configuration#experimentalnativesqlite

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

9 participants