Attempted import error: 'react-bootstrap' does not contain a default export

Viewed 586

React Bootstrap 2.0.2 is just impossible for me use because nothing can be imported. Every scrap of documentation and examples (even from the react-bootstrap folks themselves) seems to be for version 1.x. In fact, react-bootstrap's own https://github.com/react-bootstrap/code-sandbox-examples don't work when updated to use "2.0.x". I did open an issue in github, but there are people all over the web who seem to have working 2.0.x code, so I'm hoping someone knows the magic.

Please note: This question is for "react-bootstrap": "^2.0.2". Please don't point me to any questions regarding react-boostrap version 1.x. They do not apply and will be totally unhelpful.

Here's a rundown of code and the compile errors they produce.

Code + error pair #1

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

Code + error pair #2

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

Code + error pair #3

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

package.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"
    ]
  }
}

Thanks for any help you can provide!

1 Answers

After all that... Jumbotron was removed in react-bootstrap 2 / Bootstrap 5. There are Migrating to v2 for react-bootstrap and Migrating to v5 for Bootstrap pages with all the details.

Related