找不到模块:无法解决“反应”

时间:2019-05-29 13:47:30

标签: javascript reactjs

我正在学习教程,突然之间我收到了此错误。我尝试了所有可以找到但没有成功的解决方案

./ src / Components / Views / Dashboard / Notification.js 找不到模块:无法在'C:\ Users .... \ Dashboard'中解析'react'

我尝试了以下解决方案: How to fix "Module not found: Can't resolve 'react'"?

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

Dashboard.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>
             )
       }
   }

Notification.js

  import React from 'react '

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

   export default Notifications 

1 个答案:

答案 0 :(得分:0)

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

Dashboard.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>
             )
       }
   }

Notification.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