This is my first post on stackoverflow so I will try my best to keep it short, sweet, and detailed enough to hopefully find some assistance.
I'm currently trying to learn React js and when I try to install react-icons
and import an Icon, my dev server is just crashing.
npm install react-icons
package.json:
{
"name": "ecostrategy",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.14.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"bootstrap": "^5.1.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.0-rc.0",
"react-dom": "^17.0.2",
"react-icons": "^4.3.0",
"react-router-dom": "^5.3.0",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
},
- In my code I put:
import { FaGithub } from "react-icons/fa";
npm run start
Failed to compile.
./node_modules/react-icons/fa/index.esm.js
Module not found: Can't resolve '../lib' in 'D:\name\school\semester\class\project\node_modules\react-icons\fa'
- I've also tried
npm install react-icons --save
and based on the error saying it can't resolve '../lib' I even just took a guess and triednpm install lib
which didn't work. Uninstalling and reinstallingreact-icons
didn't help either.
EDIT--v
- I deleted my
node_modules
folder and rannpm install
again, this didn't fix the problem. My output after runningnpm install
was:
added 1987 packages from 789 contributors and audited 1990 packages in 103.053s
153 packages are looking for funding
runnpm fund
for details
found 3 moderate severity vulnerabilities
runnpm audit fix
to fix them, ornpm audit
for details When I trynpm audit fix
it says something about not being able to solve them automatically, andnpm fund
gives me just a list.
CodePudding user response:
Apparently there's a problem with react-icons v4.3.0. See this issue: https://github.com/react-icons/react-icons/issues/490
The solution is to downgrade to v4.2.0. Try setting this line in your package.json:
"react-icons": "4.2.0",
Then remove node_modules
and run npm install
again.
This essentially "pins" the version of react-icons
to 4.2.0
. It will never install another version. So, you'll want to keep an eye on the package. I'm sure a fix will be pushed soon. After that you can set the version back to "^4.3.0"
(or "^4.4.0"
if that's the fixed version) and see if it's resolved.
CodePudding user response:
Check this out. I think this is where you might be facing an issue