Monday, June 24, 2024

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

Must read


React is a well-liked JavaScript framework, used along with different packages, to create dynamic consumer interfaces. Nonetheless, generally these packages may cause points. One such downside 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 usually happens when the react-icons package deal isn’t put in accurately or is lacking out of your mission’s dependencies.

This package deal is a well-liked alternative for including icons to your React initiatives, and this error means your software cannot discover it within the node_modules listing.

Reinstalling Dependencies

One technique 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 won’t truly be put in.

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

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

After deleting, reinstall your dependencies utilizing npm or yarn.

$ npm set up


$ yarn

This course of will create a contemporary 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 verify the package deal.json file on your mission. In case you are not conscious, this file comprises a listing of all of the dependencies your mission wants. If react-icons isn’t listed within the dependencies object, you could set up it.

$ npm set up --save react-icons


$ yarn add react-icons

After working one in every of these instructions, react-icons needs to be added to your package deal.json file and node_modules listing, and the error needs to be resolved.

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


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

Supply hyperlink

More articles


Please enter your comment!
Please enter your name here

Latest article