Any idea how to use imports outside of a module? Trouble understanding this error:
What does this error mean by cannot use import statements outside a module? This is a mdx blog with contentlayer, and it doesn't like me using the
useMDXComponent
function.![No description](https://cdn.answeroverflow.com/1153240769692454972/image.png)
![No description](https://cdn.answeroverflow.com/1153240770090909746/image.png)
21 Replies
I'm not very well versed in how typescript works, so I'm having trouble figuring this out
if you could post your code inside a code tag like this, then it would be easier others to read and help you
![No description](https://cdn.answeroverflow.com/1153654247028691094/image.png)
I’ll do that rn
@sturlen
![No description](https://cdn.answeroverflow.com/1153655023037841429/image.png)
are you getting it?
I sent it in this thread
but i'm getting this message @sturlen
I don't see why you'd be blocked from posting here
specifically posting code weird
you might need to ask a mod then. I just answer the occasional question here
perfect thanks
had to cut a few lines empty lines
@machina0 did you add
withContentlayer
to your next config? https://contentlayer.dev/docs/reference/next-contentlayer-e6e7eb3a#withcontentlayerContentlayer
next-contentlayer – Contentlayer
Helper for improving the experience when developing with Next.js.
yeah here it is @sturlen
nothing strikes me as wrong at glance and the docs seem to agree. only idea I have is if something in the Button component is not working. have you tried importing in another component see if it works?
yeah let me try that
also does something seem wrong with the line
@sturlen
I've seen some tutorials use post.body.code there but I don't have a .code attribute in the body
it probably depends on which kind of content source you're using