问题
我在webpack中一直收到以下错误
Error: Cannot find module 'react-bootstrap-validtion'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)
我是否引用或安装模块不正确?
这是我根据官方网站的示例操作的。(https://www.npmjs.com/package/react-bootstrap-validation)
环境
这是我正在使用的node环境。
npm -v
3.10.7
nvm version
v5.11.1
node -v
v5.11.1
这是我安装模块的方法
npm install --save react-bootstrap-validation
React 组件
这是我实现 React 组件的方式
import React, {Component} from 'react'
import { ButtonInput } from 'react-bootstrap'
import { Form } from 'react-bootstrap-validation'
export default class LoginForm extends Component {
constructor(props) {
super(props)
this.state = {
showModal: false,
email: '',
password: ''
}
}
_handleValidSubmit(values) {}
_handleInvalidSubmit(errors, values) {}
render() {
return (
<div>
<div className="account">
<div className="container">
<div className="page-title">Login</div>
<div className="page-desc">Email used at sign up</div>
<Form
onValidSubmit={this._handleValidSubmit.bind(this)}
onInvalidSubmit={this._handleInvalidSubmit.bind(this)}>
<ValidatedInput
type="text"
label="Email"
name="email"
validate="required,isEmail"
errorHelp={{
required: "Please enter your e-mail",
isEmail: "Email is invalid"
}}
/>
<ValidatedInput
type="password"
label="Password"
name="password"
validate="required,isLength:6:60"
errorHelp={{
required: "Please specify a password",
isEmail: "Password must be at least 6 characters"
}}
/>
<ButtonInput
type="submit"
bsSize="large"
bsStyle="primary"
value="LOGIN"
/>
</Form>
</div>
</div>
</div>
)
}
}
在'/usr/src/app/app/js/components/main'中找不到模块:错误:无法解析'react-bootstrap-validation'
- Giwoo Gustavo Leereact-bootstrap-validation
包文件夹吗? - Hardy