gray-matter
gray-matter copied to clipboard
TypeError: gray_matter__WEBPACK_IMPORTED_MODULE_4__ is not a function
Hi there,
I am trying to use this module and, I am getting the below error;
TypeError: gray_matter__WEBPACK_IMPORTED_MODULE_4__ is not a function
// code
import * as matter from "gray-matter";
export async function getAllFilesFrontMatter(type) {
const files = readdirSync(join(process.cwd(), "data", type));
const posts = files.map((file) => {
const fileContents = readFileSync(
join(process.cwd(), "data", type, file),
"utf8"
);
const { data } = matter(file); <--- throws an error
});
return posts;
}
What could be the issue here? I am using this function in a nextjs project, not sure if the issue is to do with webpack 5
I'm seeing the same issue after upgrading my npm packages. Did you find the solution?