TypeError: gray_matter__WEBPACK_IMPORTED_MODULE_4__ is not a function #130

Open
opened 2021-09-24 13:45:45 +00:00 by joeynimu · 1 comment
joeynimu commented 2021-09-24 13:45:45 +00:00 (Migrated from github.com)

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

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 ``` ```js // 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 commented 2021-10-24 08:19:55 +00:00 (Migrated from github.com)

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

I'm seeing the same issue after upgrading my npm packages. Did you find the solution?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rtlabs-llm-agents/gms-gray-matter#130
No description provided.