首页 > 解决方案 > 找不到模块:无法解析“反应”

问题描述

我正在关注一个教程,突然间我收到了这个错误。我已经尝试了所有我能找到的解决方案,但没有成功

./src/Components/Views/Dashboard/Notification.js 未找到模块:无法解析“C:\Users....\Dashboard”中的“react”

我已经尝试过这些解决方案: 如何修复“找不到模块:无法解析‘反应’”?

https://github.com/facebook/create-react-app/issues/2534

仪表板.js

  import React, { Component} from 'react'
  import Notifications from './Notification'
  import ProjectList from '../Projects/ProjectList'

   class Dashboard extends Component {
     render() {
        return(
               <div className="dasboard container">
                    <div className="row">
                          <div className="col s12 m6">
                                <ProjectList />
                          </div>
                          <div className="col s12 m5 offset-m1">
                                <Notifications />

                          </div>
                    </div>
              </div>
             )
       }
   }

通知.js

  import React from 'react '

  const Notifications = () => {
    return(
          <div className="container">
                <p>Nostifications</p>
          </div>
      )
   } 

   export default Notifications 

标签: javascriptreactjs

解决方案


这可能无济于事,但您有一些错别字。我不确定它是否只是在 SO 上发布,但试试这个

仪表板.js

  import React, { Component} from 'react'
  import Notifications from './Notification' // Notification that you're importing isnt the same as the import name - Notifications from Notifications not Notification
  import ProjectList from '../Projects/ProjectList'

   class Dashboard extends Component {
     render() {
        return(
               <div className="dasboard container">
                    <div className="row">
                          <div className="col s12 m6">
                                <ProjectList />
                          </div>
                          <div className="col s12 m5 offset-m1">
                                <Notifications />

                          </div>
                    </div>
              </div>
             )
       }
   }

通知.js

import React from 'react ' // <- there is a space here after the react import try taking it out

  const Notifications = () => {
    return(
          <div className="container">
                <p>Nostifications</p>
          </div>
      )
   } 

   export default Notifications 

推荐阅读