未找到模块:'redux' [英] Module not found: 'redux'

查看:49
本文介绍了未找到模块:'redux'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 create-react-app cli 创建了一个新的 React 应用程序.然后我使用 npm install --save react-redux 添加了 'react-redux' 库.

package.json 我有:

"react-redux": "^4.4.5"

不幸的是,该应用程序无法编译并抱怨:

./~/react-redux/lib/utils/wrapActionCreators.js 中的错误找不到模块:C:\Users\Salman\Desktop\Courses\Internship\React\Youtube-Front-End\node_modules\react-redux\lib\utils 中的redux"@ ./~/react-redux/lib/utils/wrapActionCreators.js 6:13-29

我不知道这是什么意思?

这是完整的容器:

import React,{Component} from 'react';从'react-redux'导入{connect};类 BookList 扩展组件{渲染列表(){返回 this.props.books.map((book)=>{<li key={book.title} >{book.title}</li>});}使成为(){返回(<div><ul>{this.renderList()}

);}}函数 mapStateToProps(state){返回{书籍:state.books};}导出默认连接(mapStateToProps)(BookList);

这里是完整的package.json:

<代码>{"name": "Youtube-Front-End",版本":0.1.0",私人":真的,开发依赖":{反应脚本":0.6.1","webpack": "^1.13.2"},依赖关系":{反应":^ 15.3.2","react-dom": "^15.3.2","react-redux": "^4.4.5",youtube-api-search":0.0.5"},脚本":{开始":反应脚本开始","build": "react-scripts build","test": "反应脚本测试 --env=jsdom",弹出":反应脚本弹出"}}

解决方案

你需要安装 react-redux 和 redux 库.

npm install --save redux

I have create a new react application using create-react-app cli. Then i have added the 'react-redux' library using npm install --save react-redux.

In package.json I have:

"react-redux": "^4.4.5"

Unfortunately, the app doesn't compile and it complains with:

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

I have no idea what does it mean?

Here is the complete container:

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);

Here is complete 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"
  }
}

解决方案

You need to install react-redux but also redux library.

npm install --save redux

这篇关于未找到模块:'redux'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆