sanity
sanity copied to clipboard
Parsing error: Cannot find module 'next/babel' Require stack
Parsing error: Cannot find module 'next/babel' Require stack:
- C:\Users\bidyu\Downloads\react-app-1st\panda\node_modules\next\dist\compiled\babel\bundle.js
- C:\Users\bidyu\Downloads\react-app-1st\panda\node_modules\next\dist\compiled\babel\eslint-parser.js
- C:\Users\bidyu\Downloads\react-app-1st\panda\node_modules\eslint-config-next\parser.js
- C:\Users\bidyu\Downloads\react-app-1st\panda\node_modules@eslint\eslintrc\dist\eslintrc.cjseslint
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
npm install --save-dev @babel/core
in root directory we have to install
npm install --save-dev @babel/core @babel/preset-env
and
npm install --save-dev @babel/core
@morshedulmunna ??
i added this "eslint.workingDirectories": ["./web", "./studio"]
line in .eslintrc and it worked for me
.eslintrc looks like this
{ "extends": "@sanity/eslint-config-studio", "eslint.workingDirectories": ["./web", "./studio"] }
@morshedulmunna @judofyr @Bidmon1234 @sjelfull
For me, this was an issue with the VS Code ESLint extension when you have the nextjs app in a subfolder (app
subfolder in my case) from the root. To solve it, I created a .vscode folder in the root with a file settings.json and this contents
{
"eslint.workingDirectories": ["./app", "./another-app"]
}
This only works this way if you're using the VS Code "workspace". If you've loaded the parent folder with a lot of subfolders, you'll need to create the .vscode/settings.json
in your parent folder, but then add in the folder path to the start, so
{
"eslint.workingDirectories": ["./folder/app", "./folder/another-app"]
}
This was helpful, thanks.
My Problem
I found this error in project with PNPM, ESLint, and Monorepo architecture using Turborepo.
My Solution
add this into the ESLint config file:
parserOptions: {
babelOptions: {
presets: [require.resolve('next/babel')],
},
},
i added this
"eslint.workingDirectories": ["./web", "./studio"]
line in .eslintrc and it worked for me.eslintrc looks like this
{ "extends": "@sanity/eslint-config-studio", "eslint.workingDirectories": ["./web", "./studio"] }
@morshedulmunna @judofyr @Bidmon1234 @sjelfull
Thanks, this worked for me....