Bug at render-markdown stage of tutorial: Must use import to load ES Module #27758
-
I have been following the Next.js tutorial, and got to this step: https://nextjs.org/learn/basics/dynamic-routes/render-markdown However, when trying to run the code as given, an error is returned:
I have been looking around and think that this is perhaps something to do with Next.js not supporting ESM, and remark now apparently being ESM only. Is this right? If so, does anyone have an idea of a way around this? I have seen various other similar issues, e.g. Is the intro tutorial really not working, or am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
// next.config.js
const config = {
experimental: {
esmExternals: true,
},
}
module.exports = config (requires next@canary version) |
Beta Was this translation helpful? Give feedback.
-
Thanks all, solved by specifying v13.0.0 of remark in package.json and then running npm update. As a data point, this is likely to make us use Gatsby for our project instead, as it doesn't inspire a lot of confidence - I can see that this issue has been coming for ~2 years: #9607 |
Beta Was this translation helpful? Give feedback.
-
@leerob could you please adjust the tutorial here to use pinned - npm install remark remark-html
+ npm install remark@13 remark-html@13 thanks! |
Beta Was this translation helpful? Give feedback.
remark
(and theunified
ecosystem more broadly) is currently transitioning to ESM-only, yes. so you could try just using a previous version (remark@13
should work i think) - or you can try if it works with setting:(requires next@canary version)