gpt4 book ai didi

reactjs - 使用 React-Bootstrap 的 Webpack,大量 'Module Not Found' 错误

转载 作者:行者123 更新时间:2023-12-03 14:04:44 25 4
gpt4 key购买 nike

我刚刚开始使用 Webpack,我无法找出打包 React-Bootstrap 的最佳方法。

尝试将 React-Bootstrap 与 React 和 React-Router 打包。 React 和 React-Router 都按预期工作,但 React-Bootstrap 因错误而崩溃。我研究了 Aliasing,使用 vendor block ,并像这样引用 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']
}
}

最佳答案

react-bootstrap@0.26.0 was missing a dependency .

更新到 0.26.1 来修复它。

关于reactjs - 使用 React-Bootstrap 的 Webpack,大量 'Module Not Found' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32940209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com