contentlayerdev / contentlayer

Contentlayer turns your content into data - making it super easy to import MD(X) and CMS content in your app
https://www.contentlayer.dev
MIT License
3.32k stars 201 forks source link

Error parsing with `mdx` #585

Closed m10rten closed 9 months ago

m10rten commented 1 year ago

I got this log, it said to post a new Issue, I have replaced my username and projectname with and because I think that does not change this error.

It says Win 10, but it is Win 11 OS. I am using pnpm v8.6.6. This is my package.json deps as well, before I show the full log:

  "dependencies": {
    "@ianvs/prettier-plugin-sort-imports": "4.1.1",
    "@radix-ui/react-dialog": "1.0.5",
    "@radix-ui/react-popover": "1.0.7",
    "@radix-ui/react-slot": "1.0.2",
    "@radix-ui/react-toast": "1.1.5",
    "class-variance-authority": "0.7.0",
    "clsx": "2.0.0",
    "contentlayer": "0.3.4",
    "geist": "1.0.0",
    "lucide-react": "0.291.0",
    "next": "14.0.1",
    "next-contentlayer": "0.3.4",
    "next-themes": "0.2.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "sharp": "0.32.6",
    "shiki": "0.14.5",
    "tailwind-merge": "2.0.0",
    "tailwindcss-animate": "1.0.7"
  },
  "devDependencies": {
    "@types/node": "20.8.10",
    "@types/react": "18.2.34",
    "@types/react-dom": "18.2.14",
    "autoprefixer": "10.4.16",
    "eslint": "8.52.0",
    "eslint-config-next": "14.0.1",
    "postcss": "8.4.31",
    "rehype": "13.0.1",
    "rehype-autolink-headings": "7.0.0",
    "rehype-pretty-code": "0.10.2",
    "rehype-slug": "6.0.0",
    "remark": "15.0.1",
    "remark-gfm": "4.0.0",
    "shadcn-ui": "0.4.1",
    "tailwindcss": "3.3.5",
    "ts-node": "10.9.1",
    "tsconfig": "workspace:*",
    "typescript": "5.2.2"
  }

With the following mdx file in: /content/docs/getting-started.mdx:

---
global_id: ""
title: Getting Started
nav_title: <project>- Getting Started
description: Get started with <project>
---

## Installation

```bash
npm install <project>

Usage

In your routes files, you can use the function to create a route handler.

This file then should look something like this:

import { <function> } from "<project>"; // Import the <functionality> function

```txt

[ERROR] TypeError: Cannot read properties of undefined (reading 'inTable')
    at Object.exitCodeText (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-gfm-table@2.0.0/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
    at compile (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
    at fromMarkdown (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
    at parser (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/remark-parse@10.0.2/node_modules/remark-parse/lib/index.js:18:12)
    at Function.parse (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:273:12)
    at executor (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:393:31)
    at new Promise (<anonymous>)
    at Function.process (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:380:14)
    at process (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@mdx-js+mdx@2.3.0/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
    at onload (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@mdx-js+esbuild@2.3.0_esbuild@0.18.20/node_modules/@mdx-js/esbuild/lib/index.js:151:22)
    at requestCallbacks.on-load (D:\Users\<user>\code\<project>\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1434:28)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at handleRequest (D:\Users\<user>\code\<project>\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:729:13) [plugin @mdx-js/esbuild]

    _mdx_bundler_entry_point-8da94bdb-5343-40d9-adc1-5f8e6db4876f.mdx:0:0:
      0 │ ---
        ╵ ^

Error: Found 1 problems in 2 documents.

 └── Encountered unexpected errors while processing of 1 documents. This is possibly a bug in Contentlayer. Please open an issue.

     • "docs/getting-started.mdx": UnexpectedMDXError: Error: Build failed with 1 error:
     _mdx_bundler_entry_point-8da94bdb-5343-40d9-adc1-5f8e6db4876f.mdx:0:0: ERROR: [plugin: @mdx-js/esbuild] TypeError: Cannot read properties of undefined (reading 'inTable')
         at Object.exitCodeText (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-gfm-table@2.0.0/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
         at compile (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
         at fromMarkdown (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
         at parser (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/remark-parse@10.0.2/node_modules/remark-parse/lib/index.js:18:12)
         at Function.parse (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:273:12)
         at executor (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:393:31)
         at new Promise (<anonymous>)
         at Function.process (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:380:14)
         at process (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@mdx-js+mdx@2.3.0/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
         at onload (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@mdx-js+esbuild@2.3.0_esbuild@0.18.20/node_modules/@mdx-js/esbuild/lib/index.js:151:22)
         at requestCallbacks.on-load (D:\Users\<user>\code\<project>\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:1434:28)
         at processTicksAndRejections (node:internal/process/task_queues:95:5)
         at handleRequest (D:\Users\<user>\code\<project>\node_modules\.pnpm\esbuild@0.18.20\node_modules\esbuild\lib\main.js:729:13)

SourceFetchDataError: {
  "_tag": "HandledFetchDataError"
}

File updated: docs/index.mdx
This error shouldn't have happened. Please consider opening a GitHub issue with the stack trace below here:
https://github.com/contentlayerdev/contentlayer/issues

An unchecked error was produced.

TypeError: Cannot read properties of undefined (reading 'cacheItemsMap')
    at IEffectTotal.effect (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@contentlayer+source-files@0.3.4_esbuild@0.18.20/node_modules/@contentlayer/source-files/src/fetchData/index.ts:187:19)
    at FiberContext.evaluateNow (file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_src/Fiber/context.ts:940:54)
    at file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_src/Fiber/context.ts:576:33
    at file:///D:/Users/<user>/code/<project>/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_src/Support/Scheduler/index.ts:15:9
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

Fiber: #45 (started at: 2023-11-05T10:50:56.399Z) was supposed to continue to: <empty trace>

Fiber: #45 (started at: 2023-11-05T10:50:56.399Z) Execution trace: <empty trace>

Fiber: #45 (started at: 2023-11-05T10:50:56.399Z) was spawned by:

Fiber: #41 (started at: 2023-11-05T10:50:56.399Z) was supposed to continue to: <empty trace>

Fiber: #41 (started at: 2023-11-05T10:50:56.399Z) Execution trace: <empty trace>

Fiber: #41 (started at: 2023-11-05T10:50:56.399Z) was spawned by:

Fiber: #40 (started at: 2023-11-05T10:50:56.398Z) was supposed to continue to: <empty trace>

Fiber: #40 (started at: 2023-11-05T10:50:56.398Z) Execution trace: <empty trace>

Fiber: #40 (started at: 2023-11-05T10:50:56.398Z) was spawned by:

Fiber: #39 (started at: 2023-11-05T10:50:56.395Z) was supposed to continue to: <empty trace>

Fiber: #39 (started at: 2023-11-05T10:50:56.395Z) Execution trace: <empty trace>

Fiber: #39 (started at: 2023-11-05T10:50:56.395Z) was spawned by:

Fiber: #34 (started at: 2023-11-05T10:50:56.392Z) was supposed to continue to: <empty trace>

Fiber: #34 (started at: 2023-11-05T10:50:56.392Z) Execution trace: <empty trace>

Fiber: #34 (started at: 2023-11-05T10:50:56.392Z) was spawned by:

Fiber: #32 (started at: 2023-11-05T10:50:56.392Z) was supposed to continue to: <empty trace>

Fiber: #32 (started at: 2023-11-05T10:50:56.392Z) Execution trace: <empty trace>

Fiber: #32 (started at: 2023-11-05T10:50:56.392Z) was spawned by:

Fiber: #26 (started at: 2023-11-05T10:50:56.387Z) was supposed to continue to: <empty trace>

Fiber: #26 (started at: 2023-11-05T10:50:56.387Z) Execution trace: <empty trace>

Fiber: #26 (started at: 2023-11-05T10:50:56.387Z) was spawned by:

Fiber: #5 (started at: 2023-11-05T10:50:55.826Z) was supposed to continue to: <empty trace>

Fiber: #5 (started at: 2023-11-05T10:50:55.826Z) Execution trace: <empty trace>

Fiber: #5 (started at: 2023-11-05T10:50:55.826Z) was spawned by:

Fiber: #0 (started at: 2023-11-05T10:50:55.816Z) was supposed to continue to: <empty trace>

Fiber: #0 (started at: 2023-11-05T10:50:55.816Z) Execution trace: <empty trace>

Fiber: #0 (started at: 2023-11-05T10:50:55.816Z) was spawned by: <empty trace>

OS: win32 10.0.22621 (arch: x64)
Process: C:\Program Files\nodejs\node.exe D:\Users\<user>\code\<project>\node_modules\.pnpm\next@14.0.1_@babel+core@7.23.2_@opentelemetry+api@1.6.0_react-dom@18.2.0_react@18.2.0\node_modules\next\dist\server\lib\start-server.js
Node version: v20.9.0
Contentlayer version: 0.3.4
m10rten commented 1 year ago

My contentlayer.config.ts is almost identical to shadcn-taxonomy:contentlayer.config.js except it is TS and with less documenttypes and different fields.

m10rten commented 1 year ago

It is related to: https://github.com/contentlayerdev/contentlayer/issues/560

m10rten commented 1 year ago

Completely removing the remarkPlugins & remarkGfm from the contentlayer.config.ts cleared out the issue, so that is where it is it seems.

h11g commented 12 months ago

I encountered the same problem when I used "remark-gfm": "^4.0.0"

amankrx commented 11 months ago

I'm facing the same issue. Any use of backticks in MDX results in this issue. And it is due to the remark-gfm as well. Any possible workaround to this?

rafaelrcamargo commented 11 months ago

Downgrading remark-gfm from ^4.0.0 to 3.0.1 solves this for now.

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.