-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
SyntaxError: Unexpected token export when using NextJS #230
Comments
Getting the same issue |
I'm having the same issue. |
@malithmcr @scottsgcho @Vista1nik do any of you have a repo with the error |
you can fix the issue using Something like this in
|
@sidujjain Following your advice and https://www.npmjs.com/package/next-transpile-modules docs helped. Thanks! |
you're welcome @zemuldo! Actually I found a better solution. You just need to use
And you won't have to use |
It didn't work for me. |
this works for me...after loads of trial and error |
This worked for me! Thanks for sharing! |
huge save, worked for me #opensource for the win |
@SalahAdDin Thanks for the simple fix! |
Man you deserve something, thanks a lot |
Not all heroes wear capes |
Try to access from node_modules. It's worked on NextJs project! |
Thank you so much @sidujjain it worked ! 😍 |
Thanks for the solution. |
@padunk - I've submitted a PR to update the README. |
awesome awesome awesome 👍🏼👍🏼👌🏼🤜🏼🤛🏼 |
Works for me! Thank you for this solution! |
Thanks It worked for me. |
This works but at cost of bundle size 💀 |
Hi friends, I had the same problem and our friend @sidujjain solved the problem, but the whole package size will be added to your component. To solve this problem, use this: |
Worked a charm, thank you |
You saved my life |
This fixed it for me! |
Full working solution import React from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import d from "react-syntax-highlighter/dist/cjs/styles/prism/nord";
const CodeBlock = {
code({ node, inline, className, children, ...props }) {
const match = /language-(\w+)/.exec(className || "");
return !inline && match ? (
<SyntaxHighlighter
style={d}
language={'javascript'}
PreTag="div"
showLineNumbers={true}
customStyle={{ margin: 0, padding: ".8rem" }}
{...props}
>
{String(children).replace(/\n$/, "")}
</SyntaxHighlighter>
) : (
<code className={className} {...props}>
{children}
</code>
);
},
};
export default CodeBlock; |
path fixing true thnx. |
You are the best. You saved my life. Whenever you want I'll buy you a beer or whatever you want. |
Thank you it help me a lot :D |
thanks a lot, helped me a lot for this OS project |
Nice solution! |
A couple years late, and this still worked! Thanks for sharing 🙏 |
Describe the bug
Error appears when I trying to import any react-syntax-highlighter styles in NextJS app.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Working Syntax Highlight.
Desktop (please complete the following information):
Additional context
Full error message:
The text was updated successfully, but these errors were encountered: