[Solved] Parsing error : Cannot find module 'next/babel'

Next JS Tarif Hossain

Problem:

Usually, we often get into this problem after installing NextJS 

Parsing error: Cannot find module 'next/babel' Require stack:

D:\app\next_app\ratu-seo\node_modules\next\dist\compiled\babel\bundle.js
D:\app\next_app\ratu-seo\node_modules\next\dist\compiled\babel\eslint-parser.js
D:\app\next_app\ratu-seo\node_modules\eslint-config-next\parser.js
D:\app\next_app\ratu-seo\node_modules@eslint\eslintrc\lib\config-array-factory.js
D:\app\next_app\ratu-seo\node_modules@eslint\eslintrc\lib\index.js
D:\app\next_app\ratu-seo\node_modules\eslint\lib\cli-engine\cli-engine.js
D:\app\next_app\ratu-seo\node_modules\eslint\lib\cli-engine\index.js
D:\app\next_app\ratu-seo\node_modules\eslint\lib\api.js

Solution 1:

Create a file called .babelrc in your root directory and add this code

{
  "presets": ["next/babel"],
  "plugins": []
}

And in .eslintrc replace the existing code with

{
  "extends": ["next/babel"]
}

Solution 2:

You need to install npm with this command:

npm install --save-dev @babel/core @babel/preset-env

                                                              OR

npm install --save-dev @babel/core

Thanks for reading this article, I hope this will solve your problem.