这是我在 stackoverflow 上的第一篇文章,所以我会尽量保持简短、甜美和详细,希望能找到一些帮助。
我目前正在尝试学习 React js,当我尝试安装react-icons
和导入图标时,我的开发服务器正在崩溃。
npm install react-icons
包.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"
},
- 在我的代码中,我输入:
import { FaGithub } from "react-icons/fa";
npm run start
编译失败。
./node_modules/react-icons/fa/index.esm.js
未找到模块:无法解析 'D:\name\school\semester\class\project\node_modules\react-icons\ 中的 '../lib' F A'
我也尝试过
npm install react-icons --save
并且基于错误说它无法解决'../lib'我什至只是猜测并尝试了npm install lib
它没有工作。卸载和重新安装react-icons
也没有帮助。我删除了我的
node_modules
文件夹并npm install
再次运行,这并没有解决问题。运行后我的输出npm install
是:
添加了来自 789 个贡献者的 1987 个包,并在 103.053s 中审核了 1990 个包
153 个包正在寻找资金
运行npm fund
以获取详细信息运行
3 个中等严重性漏洞以修复它们,或获取详细信息npm audit fix
npm audit
当我尝试npm audit fix
时,它会说无法自动解决它们,并npm fund
给我一个列表。