react-data-export icon indicating copy to clipboard operation
react-data-export copied to clipboard

Error by importing the project

Open ogodon opened this issue 7 years ago • 6 comments

Hello,

I'm trying to use this exciting library. After installing the react-data-export package in my existing react application I get an error when I import the package by using import ReactExport from 'react-data-export';

I have the following error.

../framework/~/tempa-xlsx/xlsx.js
Module not found: Error: Cannot resolve module 'fs' in /home/ogodon/projects/framework/node_modules/tempa-xlsx
resolve module fs in /home/ogodon/projects/framework/node_modules/tempa-xlsx
  looking for modules in /home/ogodon/projects/company/node_modules
    /home/ogodon/projects/company/node_modules/fs doesn't exist (module as directory)
    resolve 'file' fs in /home/ogodon/projects/company/node_modules
      resolve file

Module fs cannot be found. So my question would be : is this package only meant to be used on a server context ?

Thank you for your time.

ogodon avatar Oct 19 '18 13:10 ogodon

Hi @ogodon, you need to explicitly define fs in configuration file, for example, in case of webpack, add following lines to your webpack.config.js file,

.....
node: {fs: 'empty'},
externals: [
    {'./cptable': 'var cptable'},
    {'./jszip': 'jszip'}
 ]

Hope that will help.

securedeveloper avatar Oct 19 '18 15:10 securedeveloper

I have the same error. I created a react app using create-react-app. The didn npm run eject. Added the above configs to webpack.config.js. And still get the error.

Failed to compile.

./node_modules/tempa-xlsx/ods.js
Module not found: Can't resolve 'xlsx' in 'C:\Projects\my-app\node_modules\tempa-xlsx'

xariaSg avatar Nov 21 '18 02:11 xariaSg

@xariaSg npm install xlsx --save solved it for me.

aleknak avatar Apr 16 '19 13:04 aleknak

@xariaSg npm install xlsx --save solved it for me.

The whole purpose of react-data-export is "(❗️❗️❗️The purpose of having a new library is that open source libraries either does not support styling and rest functionality in excel or they are too heavy to consider)". xlsx module is a heavy one. It has a size of 10MB. So this shouldn't be a proper solution.

xaviergeorge avatar Mar 02 '22 14:03 xaviergeorge

Hi @ogodon, you need to explicitly define fs in configuration file, for example, in case of webpack, add following lines to your webpack.config.js file,

.....
node: {fs: 'empty'},
externals: [
    {'./cptable': 'var cptable'},
    {'./jszip': 'jszip'}
 ]

Hope that will help.

Hi!

I created my project with create-react-app and didn't find where to add this setting to solve the problem.

How i can do this?

grazielleanna avatar May 26 '22 14:05 grazielleanna

Hi @ogodon, you need to explicitly define fs in configuration file, for example, in case of webpack, add following lines to your webpack.config.js file,

.....
node: {fs: 'empty'},
externals: [
    {'./cptable': 'var cptable'},
    {'./jszip': 'jszip'}
 ]

Hope that will help.

Hi!

I created my project with create-react-app and didn't find where to add this setting to solve the problem.

How i can do this?

You can check out this: https://github.com/securedeveloper/react-data-export/issues/168#issuecomment-1013556528

arindam-grene avatar Sep 14 '22 11:09 arindam-grene