简体   繁体   English

尝试导入错误:“FaBars”未从“react-icons/fa”导出

[英]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.您可以按照这些步骤操作,让我们看看它是如何进行的。

  1. Open up your terminal and type npm install -g rimraf .打开您的终端并输入npm install -g rimraf
  2. Then go to your project directory and run this rimraf node_modules package-lock.json .然后 go 到你的项目目录并运行这个rimraf node_modules package-lock.json
  3. Once deleted, run 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.

相关问题 尝试导入错误:“createLocation”未从“历史”导出 - Attempted import error : 'createLocation' is not exported from 'history' 尝试导入错误:当编译react-native到react-native-web时,不会从'./apiFetcher'导出'ApiGet' - Attempted import error: 'ApiGet' is not exported from './apiFetcher' when compile react-native to react-native-web 尝试导入错误:'Jumbotron 未从'react-bootstrap'导出(导入为'Jumbo') - Attempted import error: 'Jumbotron is not exported from 'react-bootstrap' (imported as 'Jumbo') react-icons 4.4.0 中的 6 个高严重性漏洞 - 6 high severity vulnerabilities in react-icons 4.4.0 编译失败。/src/App.js 尝试导入错误:“UserProvider”未从“./model/UserContext”导出 - Failed to compile ./src/App.js Attempted import error: 'UserProvider' is not exported from './model/UserContext' React JS导入错误-找不到模块:您试图导入不在项目src /目录下的../actions - React JS import error - Module not found: You attempted to import ../actions which falls outside of the project src/ directory 反应尝试重用标记错误 - react attempted to reuse markup error [React.js] 尝试导入错误:'./registerServiceWorker' 不包含默认导出(导入为 'registerServiceWorker') - [React.js]Attempted import error: './registerServiceWorker' does not contain a default export (imported as 'registerServiceWorker') 尝试导入错误:我的文件不包含默认导出? - Attempted import error: my file does not contain a default export? ReactJS:React尝试重用容器中的标记,但校验和为无效错误 - ReactJS: React attempted to reuse markup in a container but the checksum was invalid error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM