简体   繁体   English

使用 react-bootstrap 时出现模块未找到错误。 已尝试所有步骤

[英]I have module not found error while working with react-bootstrap. Have tried all the steps

My package.json file我的 package.json 文件

    {
  "name": "oil",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "bootstrap": "^4.6.0",
    "react": "^17.0.1",
    "react-bootstrap": "^1.4.3",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.2",
    "web-vitals": "^1.0.1"
  },
  "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"
    ]
  }
}

and my Navbar.js file和我的 Navbar.js 文件

import React, { Component } from "react";
import * as ReactBootstrap from "react-bootstrap";

const Navbar = () => {
    return (
        <div>
            <ReactBootstrap.Nav
                activeKey="/home"
                onSelect={(selectedKey) => alert(`selected ${selectedKey}`)}
            >
                <ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link href="/home">Active</ReactBootstrap.Nav.Link>ReactBootstrap.
                </ReactBootstrap.Nav.Item>

                <ReactBootstrap.ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link eventKey="link-1">Link</ReactBootstrap.Nav.Link>
                </ReactBootstrap.ReactBootstrap.Nav.Item>

                <ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link eventKey="link-2">Link</ReactBootstrap.Nav.Link>
                </ReactBootstrap.Nav.Item>

                <ReactBootstrap.Nav.Item>
                <ReactBootstrap.Nav.Link eventKey="disabled" disabled>
                    Disabled
                </ReactBootstrap.Nav.Link>
                </ReactBootstrap.Nav.Item>
            </ReactBootstrap.Nav>
        </div>
    )
}

export default Navbar

And my App.js file还有我的 App.js 文件

// import logo from './logo.svg';
import './App.css';
import Navbar from './components/Navbar'
import 'bootstrap/dist/css/bootstrap.min.css';

function App() {
  return (
    <div>
    <Navbar />
   <h2>city guide</h2>
   </div>
  );
}

export default App;

I get the following error我收到以下错误

./src/components/Navbar.js Module not found: Can't resolve 'C:\Users\Harish\react\oil\node_modules\react-scripts\node_modules\babel-loader\lib\index.js' in 'C:\Users\Harish\react\oil' ./src/components/Navbar.js 未找到模块:无法在“C”中解析“C:\Users\Harish\react\oil\node_modules\react-scripts\node_modules\babel-loader\lib\index.js” :\用户\哈里什\反应\油'

I think the problem might be in the implementation part, Can anyone help me with this?I am pretty new to react我认为问题可能出在实施部分,有人可以帮我解决这个问题吗?我对反应很陌生

My package.json file我的 package.json 文件

    {
  "name": "oil",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "bootstrap": "^4.6.0",
    "react": "^17.0.1",
    "react-bootstrap": "^1.4.3",
    "react-dom": "^17.0.1",
    "react-scripts": "4.0.2",
    "web-vitals": "^1.0.1"
  },
  "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"
    ]
  }
}

and my Navbar.js file和我的 Navbar.js 文件

import React, { Component } from "react";
import * as ReactBootstrap from "react-bootstrap";

const Navbar = () => {
    return (
        <div>
            <ReactBootstrap.Nav
                activeKey="/home"
                onSelect={(selectedKey) => alert(`selected ${selectedKey}`)}
            >
                <ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link href="/home">Active</ReactBootstrap.Nav.Link>ReactBootstrap.
                </ReactBootstrap.Nav.Item>

                <ReactBootstrap.ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link eventKey="link-1">Link</ReactBootstrap.Nav.Link>
                </ReactBootstrap.ReactBootstrap.Nav.Item>

                <ReactBootstrap.Nav.Item>
                    <ReactBootstrap.Nav.Link eventKey="link-2">Link</ReactBootstrap.Nav.Link>
                </ReactBootstrap.Nav.Item>

                <ReactBootstrap.Nav.Item>
                <ReactBootstrap.Nav.Link eventKey="disabled" disabled>
                    Disabled
                </ReactBootstrap.Nav.Link>
                </ReactBootstrap.Nav.Item>
            </ReactBootstrap.Nav>
        </div>
    )
}

export default Navbar

And my App.js file还有我的 App.js 文件

// import logo from './logo.svg';
import './App.css';
import Navbar from './components/Navbar'
import 'bootstrap/dist/css/bootstrap.min.css';

function App() {
  return (
    <div>
    <Navbar />
   <h2>city guide</h2>
   </div>
  );
}

export default App;

I get the following error我收到以下错误

./src/components/Navbar.js Module not found: Can't resolve 'C:\Users\Harish\react\oil\node_modules\react-scripts\node_modules\babel-loader\lib\index.js' in 'C:\Users\Harish\react\oil' ./src/components/Navbar.js 未找到模块:无法在“C”中解析“C:\Users\Harish\react\oil\node_modules\react-scripts\node_modules\babel-loader\lib\index.js” :\用户\哈里什\反应\油'

I think the problem might be in the implementation part, Can anyone help me with this?I am pretty new to react我认为问题可能出在实施部分,有人可以帮我解决这个问题吗?我对反应很陌生

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我正在使用 React-Bootstrap。 e.preventDefault() 不起作用 - I'm using React-Bootstrap. The e.preventDefault() is not working 反应引导。 特别是解析错误:意外的标记,预期的“,” - React-Bootstrap. Specifically with Parsing error: Unexpected token, expected "," React 一直在说。map 不是 function 并且我尝试过的没有任何工作? - React keeps saying .map is not a function and nothing I have tried is working? 如果要在div中找到两个类,我想删除类,但我尝试过但无法使用jQuery函数 - I want to remove class if two classes found in a div, with jQuery function I have tried but not working React Native Firebase 身份验证不断失败我已遵循所有必要的步骤 - React Native Firebase Auth keeps on failing I have followed all the necessary steps MongooseServerSelectionError:连接 ECONNREFUSED 127.0.0.1:27017。 我已经尝试过 StackOverflow 中给出的所有解决方案,但它不起作用 - MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017. I have tried all solutions given in the StackOverflow, but its not working CSS React JS 中的模块无法正常工作,我几乎尝试了所有方法,但没有解决 - CSS Modules in React JS not working, i have tried literally everything but it didn't solved 我试图从javascript对象中检索“员工信息”,但是在检查javascript控制台时出错 - I have tried to retrieve `employee info` from javascript object but error while checking javascript console 我尝试使用3反应导航版本运行我的drawerNavigation代码,但仍然说错误 - I have tried running my drawerNavigation code with 3 react navigation version but still says error jQuery中的NaN错误。 尝试过ParseInt,仍然无法正常工作 - NaN error in jquery. Have tried ParseInt, still not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM