ESLint says it cannot resolve a path to a module that does exist
Unable to resolve path to module 'react'. import/no-unresolvedShort answer
import/no-unresolved fails when eslint-plugin-import cannot find the file or package on disk with its resolver. By default it only knows Node's rules and the .js extension. Check that the package is installed, then tell the plugin about your .jsx or .tsx files and, for TypeScript aliases, add the TypeScript resolver.
Fix it fast
1Find out which cause you have
Find out whether the failing name is a package or one of your own files. For a package, ask npm whether it is installed; for a file, check its real name and extension.
npm ls react npx eslint --print-config src/App.jsx | grep -A8 "import/resolver"2Match what you see, then jump to its fix
- 1
The path in the message is a bare name such as 'react' and npm ls shows nothingThe package is not installed in this projectFix - 2
Relative imports like './Button' fail while 'Button.jsx' sits next to the fileThe file is .jsx or .tsx and the resolver only looks for .jsFix - 3
Imports through an alias such as '@/components/Header' fail, or .ts files are not found, in a project that builds fineTypeScript paths or aliases that the Node resolver cannot seeFix - 4
The import works on macOS or Windows but the rule still reports itFile name casing differs from the importFix
- 1
What does the error look like?
Unable to resolve path to module 'react'. import/no-unresolved
Cause 1 of 4
The package is not installed in this project
1Check
The rule resolves an import to a module on the local filesystem using Node's lookup. If node_modules does not contain the package, the lookup fails, whatever your editor shows.
npm ls react2Fix
Install the package where the code that imports it lives (in a monorepo, that workspace), then run ESLint again.
npm install react react-dom3Verify
npm lists the package and the error is gone on the next lint run.
npm ls react
npx eslint srcConfirmed by github.com
Cause 2 of 4
The file is .jsx or .tsx and the resolver only looks for .js
1Check
The plugin's default for import/extensions is ['.js'] (['.js', '.jsx'] with the react shared config). Files with other extensions are not found when you import them without the extension.
ls src/components | grep -i button2Fix
List the extensions on the Node resolver in your ESLint settings.
// .eslintrc.cjs
module.exports = {
settings: {
'import/resolver': {
node: { extensions: ['.js', '.jsx', '.ts', '.tsx'] },
},
},
};3Verify
Lint the file that failed.
npx eslint src/App.jsxConfirmed by github.com
Cause 3 of 4
TypeScript paths or aliases that the Node resolver cannot see
1Check
The default Node resolver knows nothing about tsconfig paths. The plugin's TypeScript setup needs a parser and a separate resolver package.
grep -n "paths" tsconfig.json2Fix
Install the TypeScript parser and resolver, then enable both the typescript and node resolvers in the settings.
npm install --save-dev @typescript-eslint/parser eslint-import-resolver-typescript
// eslint.config.js (flat config)
settings: {
'import/resolver': {
typescript: true,
node: true,
},
},3Verify
Lint a file that imports through the alias.
npx eslint src/app/page.tsxConfirmed by github.com
Cause 4 of 4
File name casing differs from the import
1Check
The rule's caseSensitive option is on by default and reports a path whose casing does not match the file on a case-insensitive filesystem.
git ls-files src | grep -i header2Fix
Rename the file or fix the import so both use the same casing.
git mv src/components/header.jsx src/components/Header.jsx3Verify
Lint again; the path is accepted.
npx eslint srcConfirmed by github.com
How do I stop it coming back?
- Keep resolver settings next to the ESLint config in version control, so CI and editors resolve imports the same way.
- Run the linter in CI after a clean npm ci, which exposes packages that only exist on one laptop.
- Use one casing style for component file names and never rename only the case outside git mv.
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- TaskvareA task and project-management suite: React on the web, Flutter on mobile, TypeScript underneath.
Related fixes
Web apps
Upgrading to Next.js 16: middleware becomes proxy, and the other things that break
Missing Required default.js for Parallel Route
Next.js 16 renames middleware.ts to proxy.ts and its exported function to proxy.
6 causes, each with a fixWeb apps
TypeScript 2695: left side of comma operator is unused in React code
Left side of comma operator is unused and has no side effects.ts(2695)
In JavaScript a comma between expressions evaluates all of them and keeps only the last, so the left ones are thrown away.
3 causes, each with a fixWeb apps
TypeScript says a JavaScript module implicitly has an any type
Could not find a declaration file for module 'react-materialize'. 'path/to/module-name.js' implicitly has an 'any' type.
TypeScript found the JavaScript file but no types for it, and noImplicitAny turns that into an error.
2 causes, each with a fixWeb apps
TypeScript says a function lacks an ending return statement
A function with a declared return type, such as Promise<string>, shows the red line under the type
TypeScript found a way for your function to reach its closing brace without returning a value, while the declared return type does not allow undefined.
4 causes, each with a fixWeb apps
TypeScript: property does not exist on type IntrinsicAttributes in a React component
Object literal may only specify known properties
TypeScript checks the props you write in JSX against the component's props type.
3 causes, each with a fixWeb apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fix