我遇到了以下所示的错误。我不知道哪里出了问题,请帮帮我。
我已更改webpack配置,并更新了react-hot-webpack加载器,但仍然遇到这些错误。
提前致谢。
以下是我遇到的错误:
提前致谢。
以下是我遇到的错误:
ERROR in ./~/redux-form/lib/reduxForm.js
Module not found: Error: Cannot resolve module 'react-redux' in /home/priyanka/Finalproject/node_modules/redux-form/lib
@ ./~/redux-form/lib/reduxForm.js 27:18-40
ERROR in ./~/redux-form/lib/values.js
Module not found: Error: Cannot resolve module 'react-redux' in /home/priyanka/Finalproject/node_modules/redux-form/lib
@ ./~/redux-form/lib/values.js 9:18-40
ERROR in ./~/redux-form/lib/ConnectedField.js
Module not found: Error: Cannot resolve module 'react-redux' in /home/priyanka/Finalproject/node_modules/redux-form/lib
@ ./~/redux-form/lib/ConnectedField.js 13:18-40
这是我的React代码
import { createStore, combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'
import React, { Component } from 'react';
import { reduxForm } from 'redux-form';
const reducers = {
// ... your other reducers here ...
form: formReducer // <---- Mounted at 'form'
}
const reducer = combineReducers(reducers)
const store = createStore(reducer)
class ContactForm extends Component {
render() {
const { handleSubmit } = this.props;
return (
<form onSubmit={handleSubmit}>
<div>
<label>First Name</label>
<Field name="firstName" component={React.DOM.input} type="text"/>
</div>
<div>
<label>Last Name</label>
<Field name="lastName" component={React.DOM.input} type="text"/>
</div>
<div>
<label>Email</label>
<Field name="email" component={React.DOM.input} type="email"/>
</div>
<button type="submit">Submit</button>
</form>
);
}
}
// Decorate the form component
ContactForm = reduxForm({
form: 'contact' // a unique name for this form
})(ContactForm);
export default ContactForm;
这是我的webpack配置
module.exports = {
entry: './src/index.js',
output: {
path: __dirname + '/public',
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.json$/,
loader: 'json-loader'
},
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' },
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|lib\/ckeditor)/
},
{
test: /\.s?css$/,
loaders: ['style-loader','css-loader','sass-loader']
}
]
},
resolve: {
alias: { 'react/lib/ReactMount': 'react-dom/lib/ReactMount' }
}
};