Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: gray_matter__WEBPACK_IMPORTED_MODULE_4__ is not a function #130

Open
joeynimu opened this issue Sep 24, 2021 · 1 comment
Open

Comments

@joeynimu
Copy link

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

@lumenwrites
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants