首页 > 解决方案 > 做出反应。找不到编译模块失败:无法解析“react-bootsrtap”

问题描述

我开始学习 React。我确实遵循了 youtube 上的几个教程,但是在添加https://react-bootstrap.github.io/时一直面临这个问题。我确实遵循 react-bootsrtap 网站https://react-bootstrap.github.io/getting-started/introduction上提供的所有说明。

当我在控制台中 npm-start 时,我确实看到以下消息:

Failed to compile.
./src/components/Home.jsModule not found: Can't resolve 'react-bootsrtap' in 'C:\Users\Nikolay\desktop\testsite\nikolay\nick\src\components'

当我从我的代码中删除对引导程序的任何引用时,它编译得很好。

Package.json 看起来像这样(注意包含引导程序):

{
  "name": "nick",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "bootstrap": "^3.4.1",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.1",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.2.0",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

请不要建议跑步

npm install --save react-bootstrap bootstrap

代替

npm install react-bootstrap bootstrap

因为它没有帮助

谢谢!

标签: reactjsreact-bootstrap

解决方案


推荐阅读