Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running npm run dev with next 13 and Contentlayer #655

Open
art321995 opened this issue Apr 5, 2024 · 1 comment
Open

Error when running npm run dev with next 13 and Contentlayer #655

art321995 opened this issue Apr 5, 2024 · 1 comment

Comments

@art321995
Copy link

Error when running npm run dev with next 13 and Contentlayer

"next": "14.1.4"
"next-contentlayer": "^0.3.4"

Error:

PS C:\Users\H378136\Documents\Index\React\react-next13\03-blog-next-mdx> npm run dev

03-blog-next-mdx@0.1.0 dev
next dev

file:///C:/Users/H378136/Documents/Index/React/react-next13/03-blog-next-mdx/next.config.mjs:1
const { withContentlayer } = require("next-contentlayer");
^

ReferenceError: require is not defined in ES module scope, you can use import instead
at file:///C:/Users/H378136/Documents/Index/React/react-next13/03-blog-next-mdx/next.config.mjs:1:30
at ModuleJob.run (node:internal/modules/esm/module_job:222:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:323:24)
at async loadConfig (C:\Users\H378136\Documents\Index\React\react-next13\03-blog-next-mdx\node_modules\next\dist\server\config.js:696:36)
at async nextDev (C:\Users\H378136\Documents\Index\React\react-next13\03-blog-next-mdx\node_modules\next\dist\cli\next-dev.js:197:14)
at async main (C:\Users\H378136\Documents\Index\React\react-next13\03-blog-next-mdx\node_modules\next\dist\bin\next:155:5)

Node.js v21.7.1

@davidsonaguiar
Copy link

if you use import and export instead of require and module.export it works

---> ReferenceError: require is not defined in ES module scope, you can use import instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants