react-icons import fails: module not found or icon not exported
Module 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.
Fix it fast
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-icons2Match what you see, then jump to its fix
- 1
Can't resolve 'react-icons/...' for every iconThe package is not installed in this projectFix - 2
Attempted import error: 'X' is not exported from 'react-icons/<pack>'The icon is imported from the wrong icon pack pathFix - 3
The 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
- 1
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-icons2Fix
Install it as a dependency and restart the dev server.
npm install react-icons --save3Verify
npm ls now lists it and the import resolves.
npm ls react-iconsConfirmed by github.com
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" src2Fix
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 pack3Verify
The component renders the icon.
npm run buildConfirmed by react-icons.github.io
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" src2Fix
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 buildConfirmed by react-icons.github.io
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix