我收到错误消息:找不到模块:无法解决“ reactstrap”

时间:2019-08-24 09:47:26

标签: reactjs

我正在创建一个反应导航栏。收到此错误。  找不到模块:

Can't resolve 'reactstrap' in 'C:\Users\User\Desktop\Node\MERNShoppingList\client\src\components'

./src/components/AppNavbar.js
Module not found: Can't resolve 'reactstrap' in 'C:\Users\User\Desktop\Node\MERNShoppingList\client\src\components'

此错误在构建期间发生,无法消除。

AppNavbar.js

    import React, { Component } from 'react';
    import {
        Collapse,
        Navbar,
        NavbarToggler,
        NavbarBrand,
        Nav,
        NavItem,
        NavLink,
        Container
    } from 'reactstrap';

APP.JS

    import React, {Component} from 'react';
    import AppNavbar from './components/AppNavbar';
    import 'bootstrap/dist/css/bootstrap.min.css';
    import './App.css';

    class App extends Component{
        render(){
            return(
                <div className="App">
                    <AppNavbar/>
                </div>
            );
       }
     }

    export default App;

请帮助。

5 个答案:

答案 0 :(得分:2)

一种方法是运行 npm i reactstrap --legacy-peer-deps

答案 1 :(得分:1)

您需要安装reactstrap。

npm i -S reactstrap

答案 2 :(得分:1)

尝试删除软件包并通过npm uninstall reactstrap重新安装,然后 由npm i -s reactstrap bootstrap重新安装 告诉我是否有效

答案 3 :(得分:1)

尝试使用class UserProfile(models.Model) : first_name = models.CharField(max_length=255, blank=True) second_name = models.CharField(max_length=255, blank=True) def full_name(self): """ : Return the first_name plus the last_name, with space in between. """ full_name = '%s %s' % (self.first_name, self.second_name) return full_name.strip()

在安装任何npm软件包时,建议将npm install --save reactstrap--save一起使用。

它将包添加到您的package.json中。

用于安装 npm install

用于卸载 npm install --save reactstrap 这将从package.json中删除包

答案 4 :(得分:0)

我遇到了同样的错误。

原因是打字错误

;在导入时错误地放在“

还要检查那些类型的错误。

从“ reactstrap”导入{Media}; <-错误