2016-10-17 58 views
26

我使用create-react-app cli創建了一個新的反應應用程序。 然後我使用npm install --save react-redux添加了'react-redux'庫。找不到模塊:'redux'

package.json我:

"react-redux": "^4.4.5" 

不幸的是,應用程序不編譯,並與抱怨:

Error in ./~/react-redux/lib/utils/wrapActionCreators.js 
Module not found: 'redux' in C:\Users\Salman\Desktop\Courses\Internship\React\Youtube-Front-End\node_modules\react-redux\lib\utils 

@ ./~/react-redux/lib/utils/wrapActionCreators.js 6:13-29 

我不知道這是什麼意思?

下面是完整的容器:

import React,{Component} from 'react'; 
import {connect} from 'react-redux'; 

class BookList extends Component{ 
    renderList(){ 
     return this.props.books.map((book)=>{ 
      <li key={book.title} >{book.title}</li> 
     }); 
    } 

    render(){ 

    return(
     <div> 
     <ul> 
      {this.renderList()} 
     </ul> 
     </div> 
    ); 
    } 
} 

function mapStateToProps(state){ 
    return{ 
    books:state.books 
    }; 
} 

export default connect(mapStateToProps)(BookList); 

下面是完整的package.json

{ 
    "name": "Youtube-Front-End", 
    "version": "0.1.0", 
    "private": true, 
    "devDependencies": { 
    "react-scripts": "0.6.1", 
    "webpack": "^1.13.2" 
    }, 
    "dependencies": { 
    "react": "^15.3.2", 
    "react-dom": "^15.3.2", 
    "react-redux": "^4.4.5", 
    "youtube-api-search": "0.0.5" 
    }, 
    "scripts": { 
    "start": "react-scripts start", 
    "build": "react-scripts build", 
    "test": "react-scripts test --env=jsdom", 
    "eject": "react-scripts eject" 
    } 
} 

回答

51

你需要安裝反應,終極版也是終極版庫。

npm install --save redux