ESLint fails with: Cannot find module 'next/babel'
Parsing error: Cannot find module 'next/babel'Short answer
next/babel is a Babel preset that ships inside the next package. ESLint reports that it cannot find it when the parser reads a Babel config that names the preset but next is not installed where Babel looks, or when an old @babel/eslint-parser setup is still in your ESLint config. Install dependencies in the right folder, or replace the legacy setup with eslint-config-next.
Fix it fast
1Find out which cause you have
Find which file asks for the preset, and whether next can be resolved from the folder where ESLint runs. The two commands show the Babel config in the project and the installed Next.js version.
ls .babelrc* babel.config.* 2>/dev/null grep -rn "next/babel" .babelrc* babel.config.* .eslintrc* eslint.config.* package.json 2>/dev/null npm ls next2Match what you see, then jump to its fix
- 1
npm ls next prints (empty) or a different folder than the one you run eslint in, for example in a fresh clone, a CI job without install, or a monorepo package.next is not installed where Babel looks for the presetFix - 2
Your ESLint config has parser: '@babel/eslint-parser', or a babelOptions block that lists next/babel.An old @babel/eslint-parser setup is still configuredFix - 3
A .babelrc or babel.config.js exists that you did not write on purpose, and it only contains next/babel.A leftover .babelrc keeps naming the presetFix
- 1
What does the error look like?
Parsing error: Cannot find module 'next/babel'ESLint stops on the first file with a Babel or parser error instead of listing lint results
Cause 1 of 3
next is not installed where Babel looks for the preset
1Check
The preset is part of the next package. A Babel config that lists next/babel only works when next is installed and reachable from that project.
npm ls next2Fix
Install dependencies in the project that owns the Babel config, then run ESLint from there. In a monorepo, run the install at the workspace root and run the linter inside the app that depends on next.
npm install
npx eslint .3Verify
The parsing error is gone and ESLint prints real lint results.
npx eslint . --max-warnings=0Confirmed by nextjs.org
Cause 2 of 3
An old @babel/eslint-parser setup is still configured
1Check
By default @babel/eslint-parser loads the project's Babel config (requireConfigFile is true), which is why a Babel preset can fail inside a lint run.
grep -rn "babel-parser\|eslint-parser\|babelOptions" .eslintrc* eslint.config.* package.json 2>/dev/null2Fix
Use the Next.js ESLint package instead. It brings the Next.js, React and React Hooks rules, and the setup no longer depends on a Babel file. Remove the parser lines you added by hand.
npm i -D eslint eslint-config-next
// eslint.config.mjs
import { defineConfig, globalIgnores } from 'eslint/config'
import nextVitals from 'eslint-config-next/core-web-vitals'
export default defineConfig([
...nextVitals,
globalIgnores(['.next/**', 'out/**', 'build/**', 'next-env.d.ts']),
])3Verify
Run ESLint with the CLI.
npx eslint .Confirmed by nextjs.org
Cause 3 of 3
A leftover .babelrc keeps naming the preset
1Check
A custom Babel file makes Next.js compile with Babel instead of SWC, and the file is then the source of truth, so it must name next/babel itself.
cat .babelrc
git log --oneline -- .babelrc | head -32Fix
Delete the file if nothing needs a custom Babel plugin; Next.js then uses SWC again. If you do need Babel, keep it with next/babel as the preset, and make sure next is installed (first cause).
# only if no custom Babel plugin is needed
rm .babelrc
// .babelrc when Babel is required
{ "presets": ["next/babel"] }3Verify
Run the dev server and ESLint. Neither mentions the preset.
npx next build
npx eslint .Confirmed by nextjs.org
How do I stop it coming back?
- Commit the lockfile and install with npm ci in CI before linting.
- Use eslint-config-next with the ESLint CLI instead of a hand-written parser setup.
- Delete .babelrc files that nobody needs; SWC is the default compiler.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
next build stops because of ESLint errors, and next lint is gone
next build fails because ESLint reports errors
In Next.js 15, next build runs ESLint when it is installed and fails on errors.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
Firebase Auth says the API key is not valid
Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.)
The apiKey your app sends is either empty, wrong, or blocked.
4 causes, each with a fixWeb apps
Jest fails with SyntaxError: Unexpected token when testing a Next.js component
Jest failed to parse a file.
Jest only understands plain JavaScript until a transform and a few file mappings tell it more.
3 causes, each with a fix