getStaticProps unified Nextjs error must use import to use ES Modules #152
-
So I am creating a static blog and using unified to compile the Markdown onto Html. All goes well the only error is when I require('unified') module. The error suggested me to 1.rename the index.js (in unified package) to index.cjs and use import instead or 2.in the package.json(in unified) remove the types: module
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Unified 10 uses ESM https://github.com/unifiedjs/unified/releases/tag/10.0.0 this is a planned part of the latest release #121 |
Beta Was this translation helpful? Give feedback.
Unified 10 uses ESM https://github.com/unifiedjs/unified/releases/tag/10.0.0 this is a planned part of the latest release #121
For an introduction to using ESM packages see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
In particular the workaround for Next js https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#gistcomment-3760583
Next is working on fixing ESM support, and the fixes should part of the next release vercel/next.js#27069