How to solve Module not found: Can’t resolve ‘react-transition-group’

Module not found: Can't resolve 'react-transition-group'

This article will show you how to fix Module not found: Can’t resolve ‘react-transition-group’ error in some ways, such as installing ‘react-transition-group’ package or checking dependencies in the package.json file. Let’s go into detail now.

What causes the Module not found: Can’t resolve ‘react-transition-group’?

When working with Javascript, applying the most recent syntax can sometimes be annoying because the code can run in one browser but fail in another, or the same browser with the most recent version works fine but is stuck on a lower version because it isn’t supported yet.

React-transition-group is a library developed by the React developer community. This library supports and provides developers with the components needed to create effects and interact more easily with CSS Transition in a React application.

The library provides the main components such as:

  • Transition
  • CssTransition
  • TransitionGroup


import { CSSTransition } from 'react-transition-group';


Module not found: Can’t resolve ‘react-transition-group’ error occurs when webpack can’t find react-transition-group module in your project, so how can you fix this?

How to fix this error?

Installing react-transition-group package

Because webpack reports the program is missing the react-transition-group package, so the easiest way to fix this error is reinstalling this package. You can install it with the npm or yarn command as follows:


npm i react-transition-group
yarn add react-transition-group

When you run this command in the terminal, wait until the program has finished installing the package for the project, and then run the project and see the result.


import React, { useState, useRef } from 'react';
import { Container, Button, Alert } from 'react-bootstrap';
import { CSSTransition } from 'react-transition-group';
import 'bootstrap/dist/css/bootstrap.min.css';
import './App.css';
const App = () => {
  const [button, setButton] = useState(true);
  const [showAlert, setShowAlert] = useState(false);
  const nodeRef = useRef(null);
  return (
    <Container style={{ paddingTop: '2rem' }}>
      {button && (
          onClick={() => setShowAlert(true)}
          size= "lg"
          Show Message
        classNames= "alert"
        onEnter={() => setButton(false)}
        onExited={() => setButton(true)}
          variant= "primary"
          onClose={() => setShowAlert(false)}
            Alert message
            This is an alert message.
export default App;


Once the react-transition-group module is installed, webpack can detect that you have fully configured react-transition-group and run the program normally. If not, the error still appears. You can refer to the following methods.

Checking the dependencies in the package.json file

Or you can check the dependencies in the project’s package.json file to see if it’s in the form below.


  "dependencies": {
     "react-router-dom": "^6.4.3",
    "react-scripts": "5.0.1",
    "react-transition-group": "^4.4.5",

At the time of writing, react-transition-group is on version 4.4.5, and if you install it, you can go to the library’s homepage to see the latest version of the package so you can easily update it. Good luck with these methods.


To summarize, this article has shown you how to fix the Module not found: Can’t resolve ‘react-transition-group’ error. Reinstalling the react-transition-group library will be the most comprehensive. Let’s try it to get your desired results! Have a nice day.

Maybe you are interested:

Leave a Reply

Your email address will not be published. Required fields are marked *