lewis machilika
lewis machilika

Reputation: 897

Module not found: Error: Can't resolve 'react-export-table-to-excel'

I wanted to be exporting the table to excel in react so Installed react-export-table-to-excel. However when I import through import { DownloadTableExcel } from 'react-export-table-to-excel'; it is giving me the above error I tried installing it globally but it's not working as well/. What can be the problem? Below is react-export-table-to-excel in node modules

enter image description here

enter image description here

package.json

{
  "name": "react app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@coreui/coreui": "^4.1.6",
    "@coreui/react": "^4.2.3",
    "@date-io/date-fns": "^2.14.0",
    "@date-io/dayjs": "^2.14.0",
    "@date-io/luxon": "^2.14.0",
    "@date-io/moment": "^2.14.0",
    "@emotion/react": "^11.9.3",
    "@emotion/styled": "^11.9.3",
    "@mui/x-data-grid": "^5.12.3",
    "@mui/x-date-pickers": "^5.0.0-alpha.7",
    "@mui/x-date-pickers-pro": "^5.0.0-alpha.7",
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.3.0",
    "@testing-library/user-event": "^13.5.0",
    "autoprefixer": "10.4.5",
    "axios": "^0.27.2",
    "bootstrap": "^5.1.3",
    "date-fns": "^2.28.0",
    "react": "^18.2.0",
    "react-bootstrap": "^2.4.0",
    "react-bootstrap-sweetalert": "^5.2.0",
    "react-date-range": "^1.4.0",
    "react-dom": "^18.2.0",
    "react-export-table-to-excel": "^1.0.3",
    "react-icons": "^4.4.0",
    "react-redux": "^8.0.2",
    "react-scripts": "5.0.1",
    "rsuite": "^5.15.1",
    "web-vitals": "^2.1.4",
    "xlsx": "^0.18.5"
  },
  "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"
    ]
  }
}

Upvotes: 0

Views: 3436

Answers (2)

Sulman Azhar
Sulman Azhar

Reputation: 1079

I think there is some issue with the library. Even their GitHub page has an open issue on this here. In this issue people have also suggested one alternative with full tutorial https://github.com/EdisonJpp/react-export-table-to-excel/issues/3

I would suggest using any other library for this purpose. I tried installing and importing this library but I am having the same issue. I tried all 4 versions of this library but none of them works. Even though these modules are exported from its index.txs file but still gives an error.

The sandbox that I used: https://codesandbox.io/s/zealous-neumann-t5qyeg?file=/src/App.js

Please check this StackOverflow article to get an alternative to this library How to export data to excel using react libraries

Upvotes: 1

Display name
Display name

Reputation: 467

Your error says that it was not installed properly. If you can, open command prompt in your react file and run npm i react-export-table-to-excel If you still have issues, then we would need to know the code editor that you are using to further assist you.

Many code editors also have a codeless GUI that supports installing dependencies for those who don't want to or can't do it the "old school" way.

Upvotes: 0

Related Questions