#Module '"astro:content"' has no exported member 'z'.
3 messages · Page 1 of 1 (latest)
Hi @mystic briar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
The error you're encountering suggests that the astro:content module is not correctly exporting the z and defineCollection members. These are essential for defining and configuring content collections in Astro.
Here's an example of how you should be importing and using these members:
import { z, defineCollection } from 'astro:content';
const blogCollection = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
author: z.string(),
date: z.date()
})
});
export const collections = {
'blog': blogCollection
};
(Source: Astro Docs (https://docs.astro.build/en/recipes/i18n/#use-collections-for-translated-content))
If you're still encountering the issue, it might be due to one of the following reasons:
-
You're using an outdated version of Astro. Ensure you're using Astro v2.0.0 or later as the
astro:contentmodule was added in Astro v2.0.0 (source (https://docs.astro.build/en/reference/api-reference/#content-collections-astrocontent)). -
Your TypeScript configuration might not be set up correctly. If you're using TypeScript, make sure you have
strictNullChecksenabled in yourtsconfig.jsonfile (source (https://docs.astro.build/en/guides/content-collections/#defining-collections)).