Thursday, August 17, 2023
HomeProgrammingFixing the "Module not discovered: Can't resolve 'react-icons'" Error

Fixing the "Module not discovered: Can't resolve 'react-icons'" Error


Introduction

React is a well-liked JavaScript framework, used along with different packages, to create dynamic consumer interfaces. Nonetheless, typically these packages could cause points. One such drawback is the “Module not discovered: Cannot resolve ‘react-icons'” error.

This Byte goals that will help you perceive and repair this error.

Why do you get this error?

The “Module not discovered: Cannot resolve ‘react-icons'” error sometimes happens when the react-icons bundle shouldn’t be put in accurately or is lacking out of your undertaking’s dependencies.

This bundle is a well-liked alternative for including icons to your React tasks, and this error means your utility cannot discover it within the node_modules listing.

Reinstalling Dependencies

One approach to resolve this error is by reinstalling your dependencies. You would possibly need to do that as a result of, whereas react-icons is listed as a dependency, it may not truly be put in.

Begin by deleting the node_modules listing and the package-lock.json file in your undertaking root.

$ rm -rf node_modules
$ rm package-lock.json

After deleting, reinstall your dependencies utilizing npm or yarn.

$ npm set up

or

$ yarn

This course of will create a recent node_modules listing and package-lock.json or yarn.lock file. It ensures that each one your dependencies, together with react-icons, are literally put in.

Confirm “react-icons” is a Dependency

One other factor you need to do is to examine the bundle.json file in your undertaking. In case you are not conscious, this file incorporates a listing of all of the dependencies your undertaking wants. If react-icons shouldn’t be listed within the dependencies object, you might want to set up it.

$ npm set up --save react-icons

or

$ yarn add react-icons

After operating one in every of these instructions, react-icons ought to be added to your bundle.json file and node_modules listing, and the error ought to be resolved.

Observe: At all times bear in mind to restart your improvement server after putting in new dependencies. This enables your utility to acknowledge and use the newly put in packages.

Conclusion

On this Byte, we confirmed the best way to resolve the “Module not discovered: Cannot resolve ‘react-icons'” error in React purposes. This error sometimes happens when the react-icons bundle is lacking or not truly put in, and we additionally confirmed a number of methods to resolve it.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments