N
Nuxt2mo ago
WiFi Plug

Nuxt content module: [error] Could not locate the bindings file. better_sqlite3.node

Hi I'm using pnpm package manager, I installed the nuxt content module however I run into this issue building locally and deploying. As a workaround locally I do
pnpm approve-builds
pnpm approve-builds
but I have the error on deployment too. So should i modify my deploy/build command to include this too or is there a proper workaround that's more recommended?
2 Replies
kapa.ai
kapa.ai2mo ago
Hi @WiFi Plug. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error [error] Could not locate the bindings file. better_sqlite3.node typically occurs when the native bindings for the better-sqlite3 package are missing or not properly built. This is a common issue when using pnpm, as it uses symlinks and strict node_modules structure, which can sometimes cause native modules to not be found or built as expected. Workarounds and Recommendations: 1. Environment Compatibility:
If you are using the default better-sqlite3 module (as Nuxt Content does by default), ensure your deployment environment is compatible. Specifically, your OS must have Glibc version higher than 2.29 (e.g., Debian 11, Ubuntu 20.04). You can check this with ldd --version as described in the official docs. If your environment does not meet this requirement, better-sqlite3 may fail to build or run properly, regardless of your build commands.
See: Server Hosting requirements 2. Build Process:
The official Nuxt Content documentation does not mention the need to run pnpm approve-builds as part of the standard build or deploy process. The recommended build steps are:
pnpm install
pnpm run build

pnpm install
pnpm run build

or, for Docker:
RUN pnpm i
RUN pnpm run build

RUN pnpm i
RUN pnpm run build

See: Docker deployment example 3. Native SQLite (Experimental):
If you are using Node.js v22.5.0 or above, you can enable the experimental native SQLite support in Nuxt Content, which avoids the need for better-sqlite3 entirely:
export default defineNuxtConfig({
content: {
experimental: { nativeSqlite: true },
},
})

export default defineNuxtConfig({
content: {
experimental: { nativeSqlite: true },
},
})

This is only available in Node.js v22.5.0+ and may help avoid native module issues altogether.
See: Experimental nativeSqlite 4. General Advice:
- Make sure you are not copying your local node_modules into your deployment environment (use a proper .dockerignore or similar). - If you are deploying to a platform like AWS Amplify, you may need to install sqlite3 as a dependency, as noted in the docs.
See: AWS Amplify deployment Summary:
You should not need to add pnpm approve-builds to your build or deploy commands if your environment is set up correctly and you follow the recommended deployment steps. If you continue to have issues, consider using the experimental native SQLite support (if your Node.js version allows), or double-check your deployment environment for compatibility and proper native module building. If these steps do not resolve your issue, the knowledge sources do not provide a more specific workaround for the pnpm approve-builds scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?