gray-matter icon indicating copy to clipboard operation
gray-matter copied to clipboard

TypeError: gray_matter__WEBPACK_IMPORTED_MODULE_4__ is not a function

Open joeynimu opened this issue 3 years ago • 1 comments

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

joeynimu avatar Sep 24 '21 13:09 joeynimu

I'm seeing the same issue after upgrading my npm packages. Did you find the solution?

lumenwrites avatar Oct 24 '21 08:10 lumenwrites