带有 React-Bootstrap 的 Webpack,很多 'Module Not Found' 错误
Webpack with React-Bootstrap, lots of 'Module Not Found' errors
刚开始使用Webpack,还想不出最好的React打包方式-Bootstrap.
尝试用 React 和 React-Router 打包 React-Bootstrap。 React 和 React-Router 都按预期工作,但 React-Bootstrap 因错误而爆炸。我查看了别名,使用供应商块,并且只是像这样引用 React-Bootstrap:
import ReactBootstrap from 'react-bootstrap/dist/react-bootstrap';
但这似乎很笨拙。我正在寻找 "correct" 使用 Webpack 打包 React-Bootstrap 的方法。
错误:
ERROR in ./~/react-bootstrap/lib/utils/childrenValueInputValidation.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/singlePropFrom' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib/utils
@ ./~/react-bootstrap/lib/utils/childrenValueInputValidation.js 12:39-85
ERROR in ./~/react-bootstrap/lib/BootstrapMixin.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/keyOf' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/BootstrapMixin.js 15:30-67
ERROR in ./~/react-bootstrap/lib/ButtonGroup.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/ButtonGroup.js 21:28-63
ERROR in ./~/react-bootstrap/lib/Button.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Button.js 21:36-79
ERROR in ./~/react-bootstrap/lib/Col.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Col.js 23:36-79
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 61:28-63
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 65:36-79
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/isRequiredForA11y' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 69:42-91
ERROR in ./~/react-bootstrap/lib/Grid.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Grid.js 17:36-79
ERROR in ./~/react-bootstrap/lib/Jumbotron.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Jumbotron.js 17:36-79
ERROR in ./~/react-bootstrap/lib/MenuItem.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/MenuItem.js 19:28-63
有什么我遗漏的吗?
编辑 我已经试过了:
import { Something } from 'react-bootstrap';
它没有解决问题。
我还将添加我的 webpack 配置:
module.exports = {
entry: './entry.jsx',
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
}
react-bootstrap@0.26.0 was missing a dependency.
更新到 0.26.1 以修复它。
我可以通过以下方法修复它:
$ npm install --force
刚开始使用Webpack,还想不出最好的React打包方式-Bootstrap.
尝试用 React 和 React-Router 打包 React-Bootstrap。 React 和 React-Router 都按预期工作,但 React-Bootstrap 因错误而爆炸。我查看了别名,使用供应商块,并且只是像这样引用 React-Bootstrap:
import ReactBootstrap from 'react-bootstrap/dist/react-bootstrap';
但这似乎很笨拙。我正在寻找 "correct" 使用 Webpack 打包 React-Bootstrap 的方法。
错误:
ERROR in ./~/react-bootstrap/lib/utils/childrenValueInputValidation.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/singlePropFrom' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib/utils
@ ./~/react-bootstrap/lib/utils/childrenValueInputValidation.js 12:39-85
ERROR in ./~/react-bootstrap/lib/BootstrapMixin.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/keyOf' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/BootstrapMixin.js 15:30-67
ERROR in ./~/react-bootstrap/lib/ButtonGroup.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/ButtonGroup.js 21:28-63
ERROR in ./~/react-bootstrap/lib/Button.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Button.js 21:36-79
ERROR in ./~/react-bootstrap/lib/Col.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Col.js 23:36-79
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 61:28-63
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 65:36-79
ERROR in ./~/react-bootstrap/lib/Dropdown.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/isRequiredForA11y' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Dropdown.js 69:42-91
ERROR in ./~/react-bootstrap/lib/Grid.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Grid.js 17:36-79
ERROR in ./~/react-bootstrap/lib/Jumbotron.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/elementType' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/Jumbotron.js 17:36-79
ERROR in ./~/react-bootstrap/lib/MenuItem.js
Module not found: Error: Cannot resolve module 'react-prop-types/lib/all' in /Users/alex/Documents/lifter/node_modules/react-bootstrap/lib
@ ./~/react-bootstrap/lib/MenuItem.js 19:28-63
有什么我遗漏的吗?
编辑 我已经试过了:
import { Something } from 'react-bootstrap';
它没有解决问题。
我还将添加我的 webpack 配置:
module.exports = {
entry: './entry.jsx',
output: {
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader'
}
]
},
resolve: {
extensions: ['', '.js', '.jsx']
}
}
react-bootstrap@0.26.0 was missing a dependency.
更新到 0.26.1 以修复它。
我可以通过以下方法修复它:
$ npm install --force