I have tried installing react icons, in my application I ran the npm command:
sudo npm install react-icons --save
I didn't get any errors, apart from some optional dependencies, that where skipped
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
Whenever I try to import some of the icons, I get an error
./src/components/SkiDaysCount.js Module not found: Can't resolve 'react-icons/lib/md' in ' '/home/kristoffer/ReactApps/navbar/src/components'
here are my imports:
import {Terrain} from 'react-icons/lib/md' import {SnowFlake} from 'react-icons/lib/ti' import {Calender} from 'react-icons/lib/fa'
Why am I getting this error?
EDIT:
i have also tried using the old syntax for importing, with the same issue as such:
import Calender from 'react-icons/lib/fa/calender'
To solve the error "Module not found: Error: Can't resolve 'react-icons'", make sure to install the react-icons package by opening your terminal in your project's root directory and running the command npm install react-icons and restart your dev server.
Luckily with React, we can create a new SVG component pretty easily that allows us to add our custom SVG icons anywhere we want.
When you use the v3 way of importing the icons, you should not have lib
be a part of the import path.
The icons also have the icon library name as prefix for the export.
import { FaCalendar } from 'react-icons/fa'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With