Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

react-icons import fails: module not found or icon not exported

ErrorModule not found: Error: Can't resolve 'react-icons/fa'

Short answer

react-icons is split into one subfolder per icon pack. The import path must name the pack that owns the icon, and the package must be installed. A missing package gives 'Module not found'; a wrong pack or name gives a missing export.

  • Applies to react-icons 5, React 19, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Check that the package is in your dependencies and installed. If it is, compare the import path with the icon pack the icon belongs to.

    npm ls react-icons
  2. 2Match what you see, then jump to its fix

    1. 1Can't resolve 'react-icons/...' for every iconThe package is not installed in this projectFix
    2. 2Attempted import error: 'X' is not exported from 'react-icons/<pack>'The icon is imported from the wrong icon pack pathFix
    3. 3The path is right but the named export is still reported as missing, often after copying from an older tutorialThe icon name or version does not exist in that packFix

What does the error look like?

  • Module not found: Error: Can't resolve 'react-icons/fa'
  • Attempted import error: 'FaBeer' is not exported from 'react-icons/fa'

Cause 1 of 3

The package is not installed in this project

1Check

The README installs it as a normal dependency, so it must be listed in package.json.

npm ls react-icons

2Fix

Install it as a dependency and restart the dev server.

npm install react-icons --save

3Verify

npm ls now lists it and the import resolves.

npm ls react-icons

Confirmed by github.com

Did this fix it?

Cause 2 of 3

The icon is imported from the wrong icon pack path

1Check

Each pack has its own import path, for example react-icons/fa for Font Awesome 5, react-icons/fa6 for Font Awesome 6, react-icons/md for Material Design and react-icons/lu for Lucide. An icon exists only in the pack it came from.

grep -rn "from 'react-icons" src

2Fix

Find the icon on the react-icons site, copy the pack path it shows, and import from there.

// Font Awesome 5 icon, from the fa path
import { FaBeer } from "react-icons/fa";
// an icon from Material Design lives under md, and so on for each pack

3Verify

The component renders the icon.

npm run build

Confirmed by react-icons.github.io

Did this fix it?

Cause 3 of 3

The icon name or version does not exist in that pack

1Check

Font Awesome 5 and Font Awesome 6, and Ionicons 4 and Ionicons 5, are different packs with different paths, so a name valid in one can be absent in the other.

grep -rn "react-icons/fa\|react-icons/io" src

2Fix

Search the pack on the react-icons site for the exact name, or move to the newer pack path such as fa6 or io5 and use the name the site shows for that pack.

// import the name exactly as the site shows it for that pack
import { FaBeer } from "react-icons/fa";

3Verify

The build passes with no missing-export message.

npm run build

Confirmed by react-icons.github.io

Did this fix it?

How do I stop it coming back?

  • Copy icon imports from the react-icons site, not from memory.
  • Import single icons by name from the pack path, as the README shows.
  • Keep react-icons in dependencies and commit the lock file.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.