我刚刚开始使用Webpack,我无法找到打包React-Bootstrap的最佳方法。
尝试使用React和React-Router打包React-Bootstrap。 React和React-Router都按预期工作,但React-Bootstrap出现了错误。我查看了Aliasing,使用了一个供应商块,只是引用了React-Bootstrap:
import ReactBootstrap from 'react-bootstrap/dist/react-bootstrap';
但这看起来很笨拙。我正在寻找"正确的"用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']
}
}
答案 0 :(得分:4)
react-bootstrap@0.26.0 was missing a dependency
更新到0.26.1以修复它。
答案 1 :(得分:1)
我可以用:
修复它$ npm install --force