How to fix Module not found: Can't resolve 'react-dom' in React

ReactBEGINNERHIGHUpdated Dec 9, 2025· 108 views

This error occurs when React cannot locate the react-dom package in your project dependencies. It typically happens during the build process or when starting the development server, preventing your React application from rendering.

Quick fix

Fixes Module not found: Can't resolve 'react-dom'

npm install react-dom react
  1. Install react-dom package
  2. Verify package.json contains react-dom
  3. Clear installation cache and reinstall
  4. Check for correct import statements
react — error
npm install react-dom react
Module not found: Can't resolve 'react-dom'
shell
npm install react-dom react

What this error means

This error indicates that the React bundler (typically Webpack or Vite) cannot find the react-dom package when trying to resolve imports in your code. The react-dom package is a critical dependency that provides DOM-specific methods for React, including the ability to render components in the browser. The error occurs during the module resolution phase of the build process. When your code imports from 'react-dom' or 'react-dom/client', the bundler searches through your node_modules directory to find the package. If the package is missing, not properly installed, or if there are permission issues, this error will be thrown. This is one of the most common setup errors in React projects, often occurring immediately after cloning a repository, upgrading dependencies, or when moving projects between environments.

Typical symptoms

  • Build process fails with "Module not found" error
  • Development server crashes on startup
  • Error message specifically mentions "Can't resolve 'react-dom'"
  • Application fails to render with blank screen
  • Console shows module resolution errors
  • CI/CD pipeline fails during build step

Common causes

  1. react-dom package was never installed in the project
  2. node_modules directory is missing or incomplete
  3. package-lock.json or yarn.lock is out of sync with package.json
  4. Version mismatch between React and react-dom packages
  5. Corrupted npm cache or installation
  6. Incorrect import path (e.g., importing from 'react-dom/client' without React 18)
  7. Missing dependencies after cloning a repository
  8. File system permissions preventing package installation

How to fix "Module not found: Can't resolve 'react-dom'"

1Install react-dom package

The most common fix is to install or reinstall the react-dom package. Run this command in your project root:

bash
npm install react-dom react

Or if using Yarn:

bash
yarn add react-dom react

Or with pnpm:

bash
pnpm add react-dom react

This installs both react and react-dom to ensure version compatibility. After installation, restart your development server.

2Verify package.json contains react-dom

Check that react-dom is listed in your package.json dependencies:

json
{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  }
}

The versions of react and react-dom should match. If react-dom is missing or has a different major version, update it:

bash
npm install react-dom@18.2.0

Replace with the version that matches your React version.

3Clear installation cache and reinstall

If the package appears to be installed but the error persists, clear your installation cache:

bash
# Delete node_modules and lock files
rm -rf node_modules package-lock.json

# Clear npm cache
npm cache clean --force

# Reinstall all dependencies
npm install

For Yarn:

bash
rm -rf node_modules yarn.lock
yarn cache clean
yarn install

After reinstalling, restart your development server and IDE.

4Check for correct import statements

Verify your imports match your React version. For React 18+, the import should be:

javascript
// React 18 and later
import { createRoot } from 'react-dom/client';

const root = createRoot(document.getElementById('root'));
root.render(<App />);

For React 17 and earlier:

javascript
// React 17 and earlier
import ReactDOM from 'react-dom';

ReactDOM.render(<App />, document.getElementById('root'));

If you're importing 'react-dom/client' but using React 17, either upgrade React or change to the legacy API.

5Verify node_modules installation

Check that the react-dom package actually exists in your node_modules:

bash
# Check if react-dom directory exists
ls node_modules/react-dom

# Verify react-dom package.json
cat node_modules/react-dom/package.json

If the directory is missing or corrupted, reinstall:

bash
npm install react-dom --force

Also check file permissions if you're on Linux/macOS:

bash
sudo chown -R $USER node_modules

Advanced notes

Version Compatibility: React 18 introduced breaking changes in the react-dom API. Projects created with Create React App 5+ use the new react-dom/client entry point. If you're upgrading from React 17, you must either update your index.js to use createRoot or add both react-dom versions to your dependencies.

Monorepo Considerations: In monorepo setups (using Yarn workspaces, pnpm workspaces, or npm workspaces), ensure react-dom is hoisted correctly. You may need to add it to the root package.json or configure hoisting settings.

Webpack Module Resolution: If using a custom Webpack config, verify the resolve.modules setting includes node_modules. Some configurations override this and break module resolution:

javascript
// webpack.config.js
module.exports = {
  resolve: {
    modules: ['node_modules', path.resolve(__dirname, 'src')]
  }
};

Docker and CI/CD: In containerized environments, ensure your Dockerfile or CI configuration runs npm install before the build step. Missing this step is a common cause of this error in deployment pipelines. Also consider using npm ci instead of npm install for more reliable installs in CI environments.

Peer Dependency Issues: Some packages have peer dependencies on specific react-dom versions. Check npm ls react-dom to identify version conflicts. Use npm install --legacy-peer-deps if you encounter peer dependency errors during installation.

Frequently asked questions

What does "Module not found: Can't resolve 'react-dom'" mean?
This error indicates that the React bundler (typically Webpack or Vite) cannot find the react-dom package when trying to resolve imports in your code. The react-dom package is a critical dependency that provides DOM-specific methods for React, including the ability to render components in the browser. The error occurs during the module resolution phase of the build process.
How do I fix "Module not found: Can't resolve 'react-dom'"?
This error occurs when React cannot locate the react-dom package in your project dependencies. It typically happens during the build process or when starting the development server, preventing your React application from rendering.
What causes "Module not found: Can't resolve 'react-dom'"?
react-dom package was never installed in the project node_modules directory is missing or incomplete package-lock.json or yarn.lock is out of sync with package.json
Is the "Module not found: Can't resolve 'react-dom'" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading