简体   繁体   中英

Error: Can't resolve 'bootstrap.min.css' in React JS

./src/style.css (./node_modules/css-loader/dist/cjs.js??ref--5-oneOf-4-1.?/node_modules/postcss-loader/src?.postcss.:/src/style.css) Error. Can't resolve 'bootstrap:min.css' in 'C:\react\adama\src'

I keep getting this error in my React project.

package.json

  "name": "adama",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.9",
    "@testing-library/react": "^11.2.5",
    "@testing-library/user-event": "^12.8.3",
    "bootstrap": "^4.6.0",
    "jquery": "^3.6.0",
    "react": "^17.0.1",
    "react-bootstrap": "^1.5.2",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.1"
  },

App.js

import $ from 'jquery';
import 'bootstrap/dist/css/bootstrap.min.css'
import './style.css'
import './responsive.css'

I have a bootstrap folder in my node_modules directory. I've tried various suggested fixes and nothing works. Please help.

In relation to your App.js Wouldnt it be:

import $ from 'jquery';
import './node_modules/bootstrap/dist/css/bootstrap.min.css'
import './style.css'
import './responsive.css'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM