denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.74k stars 5.21k forks source link

`next-contentlayer` with Next.js not working #21976

Open littledivy opened 7 months ago

littledivy commented 7 months ago

To reproduce:

  1. mkdir repro && cd repro
  2. deno run -A --unstable npm:degit 'timlrx/tailwind-nextjs-starter-blog'
  3. Convert next.config.js to ESM
  4. npm i
  5. deno run -A --unstable-byonm ./node_modules/.bin/next dev

In the wall of errors, you'll find:

ConfigReadError (/Users/divy/gh/demo/contentlayer.config.ts): TypeError: Cannot read properties of undefined (reading 'env') at file:///Users/divy/gh/demo/.contentlayer/.cache/v0.3.4/compiled-contentlayer-config-V47B5E7I.mjs?x=1705550689002:58:35
ConfigReadError (/Users/divy/gh/demo/contentlayer.config.ts): TypeError: Cannot read properties of undefined (reading 'env') at file:///Users/divy/gh/demo/.contentlayer/.cache/v0.3.4/compiled-contentlayer-config-V47B5E7I.mjs?x=1705550689011:58:35
littledivy commented 6 months ago

Adding an import process from "node:process" in data/siteMetadata.js fixes the issue