I encountered an initial error:
[Error] Parsing error: Cannot find module 'next/babel'
Let’s look into how to fix this. The first solution I found was this:
Create a .babelrc
file in the project root and add the following code:
{
"presets": ["next/babel"],
"plugins": []
}
Next, open the .eslintrc.json
file in the root directory. It probably looks like this:
{
"extends": ["next/core-web-vitals"]
}
You need to add next/babel
to this part:
{
"extends": ["next/babel", "next/core-web-vitals"]
}
Does that solve the problem? Yes, but…
In reality, you don’t need to add .babelrc
. Just adding next/babel
to .eslintrc.json
resolves the issue.
If it still doesn’t work, consider adding .babelrc
as well.