N
Nuxt2w ago
Angius

ERROR [unhandledRejection] near "ve": syntax error

// content.config.ts
export default defineContentConfig({
collections: {
posts: defineCollection({
type: "page",
source: "posts/*.md",
schema: z.object({
title: z.string(),
author: z.string(),
date: z.coerce.date(),
x_cat: z.string(),
})
}),
},
});
// content.config.ts
export default defineContentConfig({
collections: {
posts: defineCollection({
type: "page",
source: "posts/*.md",
schema: z.object({
title: z.string(),
author: z.string(),
date: z.coerce.date(),
x_cat: z.string(),
})
}),
},
});
// nuxt.config.ts
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
modules: ["@nuxt/content"],
});
// nuxt.config.ts
export default defineNuxtConfig({
compatibilityDate: "2024-11-01",
devtools: { enabled: true },
modules: ["@nuxt/content"],
});
// index.vue
<script setup lang="ts">
const { data, error, status } = await useAsyncData(() => queryCollection("posts").all());
</script>

<!-- snip -->

</template>
// index.vue
<script setup lang="ts">
const { data, error, status } = await useAsyncData(() => queryCollection("posts").all());
</script>

<!-- snip -->

</template>
Getting a weird error
> nuxt dev

Nuxt 3.15.3 with Nitro 2.10.4
➜ Local: http://localhost:3000/
➜ Network: use --host to expose

✔ Processed 2 collections and 17 files in 261.10ms (16 cached, 1 parsed)

ERROR [unhandledRejection] near "ve": syntax error

at Database.exec (node_modules\better-sqlite3\lib\methods\wrappers.js:9:14)
at Object.exec (/F:/blog/node_modules/@nuxt/content/dist/runtime/internal/sqlite.js:17:16)
at deleteDevelopmentCache (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:301:8)
at Object.insertDevelopmentCache (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:297:5)
at /F:/blog/node_modules/@nuxt/content/dist/module.mjs:2321:16
at async Promise.all (index 16)
at async processCollectionItems (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:2304:9)

ℹ Restarting Nuxt due to error: SqliteError: near "ve": syntax error
✔ Processed 2 collections and 17 files in 280.79ms (16 cached, 1 parsed)
> nuxt dev

Nuxt 3.15.3 with Nitro 2.10.4
➜ Local: http://localhost:3000/
➜ Network: use --host to expose

✔ Processed 2 collections and 17 files in 261.10ms (16 cached, 1 parsed)

ERROR [unhandledRejection] near "ve": syntax error

at Database.exec (node_modules\better-sqlite3\lib\methods\wrappers.js:9:14)
at Object.exec (/F:/blog/node_modules/@nuxt/content/dist/runtime/internal/sqlite.js:17:16)
at deleteDevelopmentCache (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:301:8)
at Object.insertDevelopmentCache (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:297:5)
at /F:/blog/node_modules/@nuxt/content/dist/module.mjs:2321:16
at async Promise.all (index 16)
at async processCollectionItems (/F:/blog/node_modules/@nuxt/content/dist/module.mjs:2304:9)

ℹ Restarting Nuxt due to error: SqliteError: near "ve": syntax error
✔ Processed 2 collections and 17 files in 280.79ms (16 cached, 1 parsed)
No description
3 Replies
kapa.ai
kapa.ai2w ago
Hi @Angius. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the error message and the provided code snippets, it appears you're encountering a syntax error in your Nuxt Content configuration. The error suggests there's an issue with the SQLite database that Nuxt Content uses to store and query your content. The error message "near "ve": syntax error" typically indicates a problem with the SQL syntax being used to interact with the database. However, in this case, it's likely caused by an incompatibility or configuration issue rather than a direct SQL syntax error in your code. Here are a few potential causes and solutions to consider: 1. Nuxt Content Version: Make sure you're using the latest version of Nuxt Content that's compatible with Nuxt 3.15.3. The configuration you've provided looks like it's for Nuxt Content v3, but your error message doesn't specify the version. You can try updating Nuxt Content to the latest version:
npm install @nuxt/content@latest

npm install @nuxt/content@latest

or if you're using pnpm:
pnpm add @nuxt/content@latest

pnpm add @nuxt/content@latest

2. Database Configuration: Nuxt Content v3 uses a new database system. Make sure your nuxt.config.ts includes the correct database configuration. You might need to specify the database type explicitly:
export default defineNuxtConfig({
// ... other config
content: {
database: {
type: 'sqlite' // or another supported type
}
}
})

export default defineNuxtConfig({
// ... other config
content: {
database: {
type: 'sqlite' // or another supported type
}
}
})

3. Content Collections: Your content.config.ts looks correct, but make sure all the fields in your schema match the actual content in your Markdown files. Any mismatch could potentially cause issues. 4. Clear Cache: Try clearing the Nuxt cache and temporary files:
npx nuxt cleanup

npx nuxt cleanup

5. Node.js Version: Ensure you're using a Node.js version that's compatible with Nuxt 3.15.3 and the version of Nuxt Content you're using. Node.js v18 or later is recommended. If none of these solutions work, you might need to create a minimal reproduction of the issue to get more specific help. You can do this by creating a new Nuxt project with just the essential configuration and content to reproduce the error. For more detailed information on configuring Nuxt Content v3, you can refer to the Nuxt Content documentation. If the problem persists after trying these solutions, consider opening an issue on the Nuxt Content GitHub repository with a minimal reproduction of your setup. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2w ago
<@85903769203642368> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Angius
AngiusOP2w ago
Yeah that didn't help The issue was one of the .md files had an apostrophe in the name. Removing that fixed things.

Did you find this page helpful?