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

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)

About this issue

  • Original URL
  • State: open
  • Created 9 months ago
  • Reactions: 19
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

downgrading remark-gfm to version 3.0.1 worked for me

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.

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

+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'
}

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

Any update about solution guys ? I get this error too

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.

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.

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]

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. ...

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.

downgrading remark-gfm to version 3.0.1 worked for me

Worked for me, thanks @dewanshDT