尝试导入错误:"反应引导程序"不包含默认导出



React Bootstrap 2.0.2对我来说是不可能使用的,因为什么都不能导入。每一段文档和示例(甚至是来自react引导程序的人员(似乎都适用于1.x版本https://github.com/react-bootstrap/code-sandbox-examples更新为使用"2.0.x"时不工作。我确实在github中打开了一个问题,但整个网络上似乎都有人在使用2.0.x代码,所以我希望有人知道其中的魔力。

请注意:此问题适用于"react-bootstrap": "^2.0.2"。请不要向我指出任何关于react boostrap 1.x版本的问题。它们确实不适用,而且完全没有帮助。

以下是代码及其产生的编译错误的概要。

代码+错误对#1

import foo from 'react-bootstrapt'产生Attempted import error: 'react-bootstrap' does not contain a default export

代码+错误对#2

import Jumbotron from 'react-bootstrap/Jumbotron';产生Module not found: Can't resolve 'react-bootstrap/Jumbotron' in '/home/greg/my-react-bootstrap-2-app/src'

代码+错误对#3

import { Jumbotron, Container, Button, Alert } from 'react-bootstrap';产生Attempted import error: 'Jumbotron' is not exported from 'react-bootstrap'.

软件包.json

{
"name": "my-react-bootstrap-2-app",
"version": "0.1.0",
"type": "module",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"bootstrap": "^5.1.3",
"node-sass": "^6.0.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"web-vitals": "^1.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

感谢您提供的任何帮助!

毕竟。。。Jumbotron在react bootstrap 2/bootstrap 5中被移除。有Migrating to v2 for react bootstrap和Migrating to v5 for bootstrap页面以及所有详细信息。

最新更新