content
content copied to clipboard
Could not locate the bindings file with nuxt cli
Environment
- Operating System: Windows_NT
- Node Version: v22.14.0
- Nuxt Version: 3.16.0
- CLI Version: 3.22.5
- Nitro Version: 2.11.5
- Package Manager: [email protected]
- Builder: -
- User Config: extends, modules, devtools, colorMode, ui, routeRules, future, compatibilityDate, typescript, eslint, uiPro
- Runtime Modules: @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @vueuse/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected], @nuxt/[email protected]
- Build Modules: -
Version
v3
Reproduction
npx nuxi@latest init
Description
When running the dev server with pnpm dev there is a missing bindings error with better-sqlite
Tried
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
Any updates on this issue?
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)
Issue: Cannot Start Nuxt with @nuxt/content
Steps to reproduce:
- pnpm: 10.6.2
- Node.js: v22.14.0
- Run
pnpm create nuxt@latest - Select the option pnpm
- Select the option to install
@nuxt/content(The error does not occur without@nuxt/content) cd base-project- 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 Try removing node_modules and re-install. sometimes pnpm does not detect packages properly.
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?
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
- Create Bun workspace
- Create Package inside workspace using
bun create nuxt - Select the option to install
@nuxt/content bun run dev- Error occur as the same.
I have the same issue with pnpm v10. Try pnpm approve-builds and select better-sqlite3. This worked for me. Good luck!
For NPM users, switching to the latest node version (22.14.0) fixed the issue! Any confirmation?
No, 22.14.0 and npm still broken here.
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.
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.
@farnabaz Thanks, your suggestion for experimental sqlite fixed it for us. See https://content.nuxt.com/docs/getting-started/configuration#experimentalnativesqlite
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
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 installbun pm untrusted
Helpful!
rm -rf node_modules && rm -f bun.lockb && bun install
bun pm untrusted
It works for me :)
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
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.
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-buildsand choosebetter-sqlite3to 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
- on
nuxt.config.tsadd:
export default defineNuxtConfig({
content: {
experimental: { nativeSqlite: true }
}
})
- remove
node_modulesandpnpm-lock.yaml - then run
pnpm i
pnpm rebuild better-sqlite3
# use space to choose better-sqlite3
pnpm approve-builds
- finally, run
pnpm dev -oit works.
I've the same issue with yarn :/
Did you also try
- Installing latest node22
- Adding
content: { experimental: { nativeSqlite: true } }in nuxt.config.ts - Aprove build scripts with
pnpm approve-buildsor yarn equivelant - Restarting the dev server
Just tried with pnpm and that worked
Is there also a fix for deno? I understood that better-sqlite3 only works with node and bun😭
Operating System: Mac Nuxt Version: 4.0.2 Node Version: v20.19.4 pnpm Version: 10.13.1
on
package.jsonfile I added this:{ .... "packageManager": "[email protected]", "pnpm": { "onlyBuiltDependencies": [ "better-sqlite3" ] } }I just removed the
node_modulesthen runpnpm iand it worked. But I needed to do it 2 times until it worked.
Thanks for your answer it works on me!
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