【问题标题】:Used Yarn to install reactstrap but getting "Can't resolve 'reactstrap' "error使用 Yarn 安装 reactstrap 但出现“无法解析 'reactstrap'”错误
【发布时间】:2020-05-20 13:21:28
【问题描述】:

我使用 yarn 安装了 bootstrap、react-popper 和 reactstrap,但页面显示以下错误“无法解析 'reactstrap'”。

我的 package.json 看起来像这样:

{
  "name": "confusion",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "bootstrap": "^4.5.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-popper": "^2.2.3",
    "react-scripts": "3.4.1",
    "reactstrap": "^8.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"
    ]
  }
}

这就是我编写 App.js 的方式:

import React from 'react';
import logo from './logo.svg';
import { Navbar, NavbarBrand } from 'reactstrap'
import './App.css';

function App() {
  return (
    <div className="App">
      <Navbar dark color="primary">
        <div className="container">
          <NavbarBrand href="/">Ristorante Con Fusion</NavbarBrand>
        </div>
      </Navbar>
    </div>
  );
}

export default App;

如何让页面显示 boostrap 导航栏?谢谢。

【问题讨论】:

    标签: reactjs reactstrap


    【解决方案1】:

    这是我从一个解决问题的同学那里得到的解决方案。该应用程序现在可以运行了。

    1. Reboot pc.
    
    2.Delete node_modules folder.
    
    3. In terminal run command 'yarn cache clean'
    
    4. Delete 'package-lock.json', 'yarn.lock' files but keep "package.json'
    
    5. In terminal run command 'yarn install'
    
    6. In terminal run command 'yarn start'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-25
      • 2021-04-03
      • 2018-07-26
      • 2019-12-29
      • 2018-06-23
      • 2018-05-20
      • 2021-12-16
      • 2021-07-07
      相关资源
      最近更新 更多