【问题标题】:react-bootstrap-table2-paginator throwing error like Module not found: Can't resolve 'classnames'react-bootstrap-table2-paginator 抛出错误,如 Module not found: Can't resolve 'classnames'
【发布时间】:2020-10-14 22:49:13
【问题描述】:

在运行我使用 react-bootstrap-table2-paginator 的项目时出现以下错误。但是我已经安装了模块,请看下图...

./node_modules/react-bootstrap-table2-paginator/lib/src/pagination.js
Module not found: Can't resolve 'classnames' in '/home/edu/pagination/node_modules/react-bootstrap-table2-paginator/lib/src'

我的app.js文件如下:

import React, { Component } from 'react';
import BootstrapTable from 'react-bootstrap-table-next';
import paginationFactory from 'react-bootstrap-table2-paginator';

const dataMovie = [{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' },
{ id: 1, title: 'Conan the Barbarian', year: '1982' },
{ id: 2, title: 'Conan the Barbarian', year: '1983' },
{ id: 3, title: 'Conan the Barbarian', year: '1984' },
{ id: 4, title: 'Conan the Barbarian', year: '1985' },
{ id: 5, title: 'Conan the Barbarian', year: '1986' } ];
const columns = [
  {
    datafield : 'id',
    text: 'ID'
  },
  {
    datafield:'title',
    name: 'Title',
  },
  {
    datafield: 'Year',
    name: 'year',

  },
];



class App extends Component {
  render() {
    return (
      <BootstrapTable keyField='id' data={ dataMovie } columns={ columns } pagination={ paginationFactory() } />
    )
  }
};

export default App;

package.json 中的依赖项

    "react": "^16.13.1",
    "react-bootstrap-table2-paginator": "^2.1.2",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"

我已经使用流动命令安装了 react-bootstrap-table2-paginator

 npm install react-bootstrap-table2-paginator --save

【问题讨论】:

  • 我这边没有收到这个错误

标签: reactjs pagination


【解决方案1】:
  1. 添加
"dependencies": {
     "classnames": "^2.2.6"
},

在 /react-bootstrap-table2-paginator/package.json 里面的 node_modules。

  1. 在 /react-bootstrap-table2-paginator/ 中运行:npm update。

查看更多https://github.com/react-bootstrap-table/react-bootstrap-table2/pull/1491/files

【讨论】:

    猜你喜欢
    • 2022-10-20
    • 2019-03-11
    • 2019-01-14
    • 2019-03-11
    • 2020-04-07
    • 2019-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多