content icon indicating copy to clipboard operation
content copied to clipboard

Could not locate the bindings file with nuxt cli

Open Rednas83 opened this issue 8 months ago • 14 comments

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 avatar Mar 14 '25 11:03 Rednas83

Any updates on this issue?

Suv4o avatar Mar 16 '25 23:03 Suv4o

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 avatar Mar 17 '25 09:03 farnabaz

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)

jordyfontoura avatar Mar 21 '25 14:03 jordyfontoura

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

farnabaz avatar Mar 21 '25 14:03 farnabaz

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?

Rednas83 avatar Mar 21 '25 18:03 Rednas83

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.

MukurowZ avatar Apr 01 '25 10:04 MukurowZ

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

2giosangmitom avatar Apr 01 '25 15:04 2giosangmitom

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

justindefodji avatar Apr 02 '25 00:04 justindefodji

No, 22.14.0 and npm still broken here.

infabo avatar Apr 02 '25 08:04 infabo

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.

farnabaz avatar Apr 04 '25 13:04 farnabaz

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.

kingyue737 avatar Apr 05 '25 08:04 kingyue737

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

infabo avatar Apr 07 '25 16:04 infabo

I managed to get passed this error with the following

Bun: 1.1.34 Operating System: Alpine Linux Nuxt Version: 3.16.0 Node Version: 22

Step to resolve

// package.json
  "devDependencies": {
    "better-sqlite3": "^11.10.0",
    "node-gyp": "^11.2.0",
    "ufo": "1.5.3",
  },

bun install bun pm untrusted

miketierce avatar May 19 '25 18:05 miketierce

I managed to get passed this error with the following我通过以下方式成功绕过了这个错误

Bun: 1.1.34 Operating System: Alpine Linux操作系统:Alpine Linux Nuxt Version: 3.16.0  Nuxt 版本:3.16.0 Node Version: 22  Node 版本:22

Step to resolve  解决步骤

// package.json
  "devDependencies": {
    "better-sqlite3": "^11.10.0",
    "node-gyp": "^11.2.0",
    "ufo": "1.5.3",
  },

bun install bun pm untrusted

Helpful!

 rm -rf node_modules && rm -f bun.lockb && bun install
bun pm untrusted

It works for me :)

chenkigba avatar Jul 01 '25 01:07 chenkigba

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.

I replaced nativeSqlite: true with sqliteConnector: 'native'. Now works fine with v3.6.1 on Windows

kingyue737 avatar Jul 10 '25 10:07 kingyue737

Operating System: Mac Nuxt Version: 4.0.2 Node Version: v20.19.4 pnpm Version: 10.13.1

on package.json file I added this:

{
  ....
 "packageManager": "[email protected]",
  "pnpm": {
    "onlyBuiltDependencies": [
      "better-sqlite3"
    ]
  }
}

I just removed the node_modules then run pnpm i and it worked. But I needed to do it 2 times until it worked.

anangyoga avatar Jul 30 '25 04:07 anangyoga

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)

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.

@farnabaz Thanks, it helps for me

  • os: windows 11 24h2
  • pnpm: 10.8.0
  • nuxt: 4.0.3
  • node: 22.14.0
  1. on nuxt.config.ts add:
export default defineNuxtConfig({
  content: {
    experimental: { nativeSqlite: true }
  }
})
  1. remove node_modules and pnpm-lock.yaml
  2. then run
pnpm i
pnpm rebuild better-sqlite3
# use space to choose better-sqlite3
pnpm approve-builds
  1. finally, run pnpm dev -o it works.

cc01cc avatar Aug 22 '25 17:08 cc01cc

I've the same issue with yarn :/

Br4x avatar Sep 02 '25 08:09 Br4x

Did you also try

  • Installing latest node22
  • Adding content: { experimental: { nativeSqlite: true } } in nuxt.config.ts
  • Aprove build scripts with pnpm approve-builds or yarn equivelant
  • Restarting the dev server

Just tried with pnpm and that worked

Rednas83 avatar Sep 04 '25 14:09 Rednas83

Is there also a fix for deno? I understood that better-sqlite3 only works with node and bun😭

Rednas83 avatar Sep 06 '25 14:09 Rednas83

Operating System: Mac Nuxt Version: 4.0.2 Node Version: v20.19.4 pnpm Version: 10.13.1

on package.json file I added this:

{
  ....
 "packageManager": "[email protected]",
  "pnpm": {
    "onlyBuiltDependencies": [
      "better-sqlite3"
    ]
  }
}

I just removed the node_modules then run pnpm i and it worked. But I needed to do it 2 times until it worked.

Thanks for your answer it works on me!

yapinxxx avatar Sep 19 '25 10:09 yapinxxx

In fact, you can avoid better-sqlite3 errors by using Bun's own built-in SQLite support, which can be enabled by adding the --bun parameter.

For further details, please refer to the official documentation: https://bun.com/docs/cli/run#bun

AQian0 avatar Oct 07 '25 16:10 AQian0