Borislav Hadzhiev
Wed Mar 16 2022·2 min read
Photo by Themodern
To solve the error "Module not found: Error: Can't resolve
'react-transition-group'", make sure to install the package by opening your
terminal in your project's root directory and running the command
npm install react-transition-group
and restart your development server.
Open your terminal in your project's root directory (where your package.json
file is located) and run the following commands:
# 👇️ with NPM npm install react-transition-group # 👇️ ONLY If you use TypeScript npm install --save-dev @types/react-transition-group # ---------------------------------------------- # 👇️ with YARN yarn add react-transition-group # 👇️ ONLY If you use TypeScript yarn add @types/react-transition-group --dev
The command will add the react-transition-group package to the dependencies of your project.
npm start
command.You should now be able to import and use the react-transition-group
package in
your React.js app.
If the error is not resolved, try to delete your node_modules
and
package-lock.json
(not package.json
) files, re-run npm install
and restart
your IDE.
# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # 👇️ clean npm cache npm cache clean --force npm install
If you're still getting the "Module not found: Error: Can't resolve
'react-transition-group'" error, open your package.json
file and make sure it
contains the react-transition-group
package in the dependencies
object.
{ // ... rest "dependencies": { "react-transition-group": "^4.4.2", }, "devDependencies": { "@types/react-transition-group": "^4.4.4", } }
The react-transition-group
module should NOT be globally installed or be in
your project's devDependencies
, it should be in the dependencies
object in
your package.json
file.
You can try to manually add the lines and re-run npm install
.
npm install
Or install the latest version of the package:
npm install react-transition-group@latest # 👇️ ONLY If you use TypeScript npm install --save-dev @types/react-transition-group@latest