[英]Attempted import error: 'FaBars' is not exported from 'react-icons/fa'
After using the command npm install react-icons
, import { FaBeer } from 'react-icons/fa'
in my script is not working and the error message is Attempted import error: 'FaBars' is not exported from 'react-icons/fa'.
使用命令
npm install react-icons
后,我的脚本中import { FaBeer } from 'react-icons/fa'
不起作用,错误消息是Attempted import error: 'FaBars' is not exported from 'react-icons/fa'.
The script was working previously and all of sudden, it stops working for no reasons.该脚本之前一直在工作,突然间,它无缘无故地停止工作。 I then tried to download the previous commit in gitlab (it must be working before), and still it is not working.
然后我尝试下载 gitlab 中的先前提交(它之前必须工作),但仍然无法工作。 The
index.js
in the /node_moudles/react-icons/fa/index.js
is weird as it is now different from the old version. /node_moudles/react-icons/fa/index.js
中的index.js
很奇怪,因为它现在与旧版本不同。 It's nearly emoty.这几乎是情绪化的。 node_modules/react-icons/fa/index.js
node_modules/react-icons/fa/index.js
Welcome to stackoverflow.欢迎来到计算器。 I don't have the entire picture of your problem yet but it's probably a dependency issue.
我还没有你问题的全貌,但这可能是一个依赖性问题。 Can you try deleting node_modules and your package-lock.json.
您可以尝试删除 node_modules 和您的 package-lock.json。 I personally use rimraf to make the process easier.
我个人使用 rimraf 来简化这个过程。 You can follow these steps and let's see how it goes.
您可以按照这些步骤操作,让我们看看它是如何进行的。
npm install -g rimraf
.npm install -g rimraf
。rimraf node_modules package-lock.json
.rimraf node_modules package-lock.json
。npm install
to get a fresh install of your dependencies.npm install
以全新安装您的依赖项。 Try running your app again to see if that solved the issue.尝试再次运行您的应用,看看是否解决了问题。 Thanks!
谢谢!
The right path is ( import { FaTimes } from 'react-icons/fa' ), because the fa icon and others are in a folder called ( react-icons) not react..正确的路径是( import { FaTimes } from 'react-icons/fa' ),因为 fa 图标和其他在一个名为( react-icons )的文件夹中没有反应..
Change the path to the above mentioned path..将路径更改为上述路径..
For further explanation, If you want to see the path for yourself, click on node_modules, look for the react folder and the react-icons folder.. When you click on the react folder, you wont see icons in it, but if you click on the react-icons folder, you will see all the icons in it.. That means you import path should be ( import { FaTimes } from 'react-icons/fa' ).如需进一步说明,如果您想自己查看路径,请单击 node_modules,查找 react 文件夹和 react-icons 文件夹。当您单击 react 文件夹时,您不会在其中看到图标,但如果您单击在 react-icons 文件夹中,您将看到其中的所有图标。这意味着您的导入路径应该是( import { FaTimes } from 'react-icons/fa' )。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.