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.27k stars 200 forks source link

TypeError: Cannot read properties of undefined (reading 'inTable') #558

Open jahirfiquitiva opened 11 months ago

jahirfiquitiva commented 11 months ago

Using Next.js v 13.5.1 I get this error when building the project

✘ [ERROR] TypeError: Cannot read properties of undefined (reading 'inTable')
    at Object.exitCodeText (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
    at compile (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-from-markdown/lib/index.js:353:40)
    at fromMarkdown (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
    at parser (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/mdx/node_modules/remark-parse/lib/index.js:15:12)
    at Function.parse (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:273:12)
    at executor (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:393:31)
    at new Promise (<anonymous>)
    at Function.process (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:380:14)
    at process (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
    at onload (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/esbuild/lib/index.js:151:22) [plugin @mdx-js/esbuild]

    _mdx_bundler_entry_point-a54d9f98-ef5f-4df9-8c0b-7c9b55c2c777.mdx:0:0:
      0 │ ---
        ╵ ^

Error: Found 8 problems in 15 documents.

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

     • "23-changes-in-2023.mdx": UnexpectedMDXError: Error: Build failed with 1 error:
     _mdx_bundler_entry_point-b47e654d-45e4-405e-bc50-b36b47de128f.mdx:0:0: ERROR: [plugin: @mdx-js/esbuild] TypeError: Cannot read properties of undefined (reading 'inTable')
         at Object.exitCodeText (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
         at compile (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-from-markdown/lib/index.js:353:40)
         at fromMarkdown (file:///Users/jahir/dev/jahir/website/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
         at parser (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/mdx/node_modules/remark-parse/lib/index.js:15:12)
         at Function.parse (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:273:12)
         at executor (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:393:31)
         at new Promise (<anonymous>)
         at Function.process (file:///Users/jahir/dev/jahir/website/node_modules/unified/lib/index.js:380:14)
         at process (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
         at onload (file:///Users/jahir/dev/jahir/website/node_modules/@mdx-js/esbuild/lib/index.js:151:22)
alex289 commented 11 months ago

+1, but I only have this problem on Vercel.

Running pnpm next build works locally for me.

But I get another error when running pnpm contentlayer build:

❯ p contentlayer build
Generated 8 documents in .contentlayer
TypeError: The "code" argument must be of type number. Received an instance of Object
    at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
    at Cli.runExit (/Users/alex/dev/Portfolio/node_modules/.pnpm/clipanion@3.2.1_typanion@3.13.0/node_modules/clipanion/lib/advanced/Cli.js:232:26)
    at run (file:///Users/alex/dev/Portfolio/node_modules/.pnpm/@contentlayer+cli@0.3.4_esbuild@0.18.13/node_modules/@contentlayer/cli/src/index.ts:39:3)
    at main (/Users/alex/dev/Portfolio/node_modules/.pnpm/contentlayer@0.3.4_esbuild@0.18.13/node_modules/contentlayer/bin/cli.cjs:5:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}
jahirfiquitiva commented 11 months ago

Oh, this seems to be an issue with the latest remark-gfm https://github.com/remarkjs/remark-gfm/issues/57

Contentlayer probably needs updating its dependencies

timtbdev commented 11 months ago

I got the same error message since I upgraded my project to Next.js 13.5. I am looking forward it this issue will be fixed soon.

Svish commented 11 months ago

I updated my project and got these errors as well. Quickly jumped to blaming next, but reverting all my updates and doing them one by one it seems that the actual causes of issues in my case are these four:

image

If I upgrade remark-gfm or remark-math, then I get same/similar errors to what's mentioned in this issue. If I upgrade rehype-highlight or rehype-katex, then I get another kind of error.

It's probably still this contentlayer project that needs to be updated somehow, since the errors come from either they contentlayer config, or from processing the content pages, but yeah... It doesn't seem to me that next@13.5 is actually related here.

My website is running with next@13.5.2 (latest) and contentlayer@0.3.4 (latest) now, without issues.

jahirfiquitiva commented 11 months ago

@schickling any chance of getting a dependencies update soon? 🙏

imyuanli commented 11 months ago

Many plugins have this similar error, remark math, rehype-highlight, remark codes and box, and soon

dewanshDT commented 11 months ago

downgrading remark-gfm to version 3.0.1 worked for me

bradlocking commented 11 months ago

downgrading remark-gfm to version 3.0.1 worked for me

Worked for me, thanks @dewanshDT

fuma-nama commented 11 months ago

Seems like Contentlayer doesn't support remark 15+ for now, if you take a look at their changelog, they also changed some typings. This also resulted in several type errors on my project, hope this will be fixed soon.

sohanemon commented 11 months ago

downgrading remark-gfm to version 3.0.1 worked for me

it really works. I see the issue is happening when I try to write something in a code format. ...

tygrdotdev commented 11 months ago

remark-gfm@4.0 works for me, however rehype-pretty-code@0.10.1 does not

timlrx commented 11 months ago

The changes are being propagated to the entire remark / rehype ecosystem. contentlayer would have to wait for mdx and mdx-bundler to be updated before it can be updated. In the meantime, just use the previous major version.

RMahammad commented 10 months ago

Any update about solution guys ? I get this error too

jaswrks commented 9 months ago

Parsing error: Cannot set properties of undefined (setting 'inTable') eslint

Still getting this error after updating to:

"@mdx-js/mdx": "^3.0.0",

        "remark": "^15.0.1",
        "remark-directive": "^3.0.0",
        "remark-frontmatter": "^5.0.0",
        "remark-gfm": "^4.0.0",
        "remark-lint": "^9.1.2",
        "remark-mdx-frontmatter": "^4.0.0",
        "remark-mermaidjs": "^6.0.0",
        "remark-preset-lint-recommended": "^6.1.3",
        "remark-preset-prettier": "^2.0.1",
        "remark-smartypants": "^2.0.0",
---
Foo: Bar
---

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

Markup on 2023-11-26 at 01:28:43

stale[bot] commented 7 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.

kachkaev commented 7 months ago

not stale (upgrades of remark-gfm from v3 to v4 are still blocked)

rusakovic commented 7 months ago

Confirm the issue.

#12 4.739 ✘ [ERROR] TypeError: Cannot read properties of undefined (reading 'inTable')
#12 4.739 at Object.exitCodeText (file:///app/node_modules/.pnpm/mdast-util-gfm-table@2.0.0/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
#12 4.739 at compile (file:///app/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
#12 4.739 at fromMarkdown (file:///app/node_modules/.pnpm/mdast-util-from-markdown@1.3.1/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
#12 4.739 at parser (file:///app/node_modules/.pnpm/remark-parse@10.0.2/node_modules/remark-parse/lib/index.js:18:12)
#12 4.739 at Function.parse (file:///app/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:273:12)
#12 4.739 at executor (file:///app/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:393:31)
#12 4.739 at new Promise (<anonymous>)
#12 4.739 at Function.process (file:///app/node_modules/.pnpm/unified@10.1.2/node_modules/unified/lib/index.js:380:14)
#12 4.739 at process (file:///app/node_modules/.pnpm/@mdx-js+mdx@2.3.0/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
#12 4.739 at onload (file:///app/node_modules/.pnpm/@mdx-js+esbuild@2.3.0_esbuild@0.20.0/node_modules/@mdx-js/esbuild/lib/index.js:151:22) [plugin @mdx-js/esbuild]
whale2002 commented 6 months ago

downgrading remark-gfm to version 3.0.1 worked for me

thank you, it works!!!

naymurdev commented 5 months ago

3.0.1

did you solve it

+1, but I only have this problem on Vercel.

Running pnpm next build works locally for me.

But I get another error when running pnpm contentlayer build:

❯ p contentlayer build
Generated 8 documents in .contentlayer
TypeError: The "code" argument must be of type number. Received an instance of Object
    at process.set [as exitCode] (node:internal/bootstrap/node:123:9)
    at Cli.runExit (/Users/alex/dev/Portfolio/node_modules/.pnpm/clipanion@3.2.1_typanion@3.13.0/node_modules/clipanion/lib/advanced/Cli.js:232:26)
    at run (file:///Users/alex/dev/Portfolio/node_modules/.pnpm/@contentlayer+cli@0.3.4_esbuild@0.18.13/node_modules/@contentlayer/cli/src/index.ts:39:3)
    at main (/Users/alex/dev/Portfolio/node_modules/.pnpm/contentlayer@0.3.4_esbuild@0.18.13/node_modules/contentlayer/bin/cli.cjs:5:3) {
  code: 'ERR_INVALID_ARG_TYPE'
}

did you find any solution?

aikins01 commented 5 months ago

still have to be on remark-gfm 3.0.1

stale[bot] commented 3 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.

kachkaev commented 3 months ago

not stale

nvegater commented 2 months ago

No update yet? :(

kachkaev commented 2 months ago

@nvegater I have managed to mitigate this issue by temporarily switching to a fork: https://github.com/timlrx/contentlayer2. Context: https://github.com/contentlayerdev/contentlayer/issues/651#issuecomment-2030335434.

UPD (2024-07-07) I switched to https://github.com/zce/velite and it’s even better!

BhatNishanthGanesh commented 2 months ago

downgrading remark-gfm to version 3.0.1 worked for me

Thanks , it works!

shrivatsabhat commented 2 weeks ago

downgrading remark-gfm to version 3.0.1 worked for me

Thank you it works.

it looks like we still have to use remark-gfm@3.0.1