securedeveloper / react-data-export

Export dataset in react.
https://securedeveloper.github.io/react-data-export/
MIT License
179 stars 194 forks source link

Resolve dependencies in react-parcel project #67

Closed adityafuture01 closed 5 years ago

adityafuture01 commented 6 years ago

Hi,

I working on a react project which is built on Parcel bundler instead of Webpack.

React Data Export used file-saver, json-loader and xlsx. I have installed all these dependencies in my package.json. But the application still throwing the below error,

Uncaught Error: Cannot find module 'jszip' at newRequire (src.61e5e814.js:39) at localRequire (src.61e5e814.js:54) at make_xlsx (xlsx.js:1344) at Object.parcelRequire.../node_modules/react-data-export/node_modules/xlsx/xlsx.js../dist/cpexcel (xlsx.js:6)

I have also installed the 'jszip' module. But same result.

How can I fix this issue?

Thanks, Adi

securedeveloper commented 6 years ago

Hello @adityafuture01, If you are using any bundler which is not doing auto dependency handling you need to install those manually, in your case you are missing jszip, please try to install it manually just like you did for other dependencies and see if that work. If not please get back with your error message and we can analyse it further.

adityafuture01 commented 6 years ago

Hello @securedeveloper, I did install the jszip in my project but the error is still the same. Below is the error complete stacktrace,

The version of installed dependencies are, file-saver: 1.3.8 json-loader: 0.5.7 jszip: 3.1.5, xlsx: 0.13.3

I see the following dependencies in react data export package.json.

"dependencies": { "file-saver": "1.3.3", "xlsx": "git+https://github.com/securedeveloper/js-xlsx.git" },

With the same project everything was working fine on last Friday. I was able to export the data into file. It is not since late last Friday. I have verified all my code and all looks good. When I uninstall the react data export and its dependencies everything is good.

Error stacktrace: Uncaught Error: Cannot find module 'jszip' at newRequire (src.61e5e814.js:39) at localRequire (src.61e5e814.js:54) at make_xlsx (xlsx.js:1344) at Object.parcelRequire.../node_modules/react-data-export/node_modules/xlsx/xlsx.js../dist/cpexcel (xlsx.js:6) at newRequire (src.61e5e814.js:48) at localRequire (src.61e5e814.js:54) at Object.parcelRequire.../node_modules/react-data-export/dist/ExcelPlugin/components/ExcelFile.js.react (ExcelFile.js:19) at newRequire (src.61e5e814.js:48) at localRequire (src.61e5e814.js:54) at Object.parcelRequire.../node_modules/react-data-export/dist/index.js../ExcelPlugin/components/ExcelFile (index.js:7) newRequire @ src.61e5e814.js:39 localRequire @ src.61e5e814.js:54 make_xlsx @ xlsx.js:1344 parcelRequire.../node_modules/react-data-export/node_modules/xlsx/xlsx.js../dist/cpexcel @ xlsx.js:6 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../node_modules/react-data-export/dist/ExcelPlugin/components/ExcelFile.js.react @ ExcelFile.js:19 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../node_modules/react-data-export/dist/index.js../ExcelPlugin/components/ExcelFile @ index.js:7 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../src/component/QuestionnaireListTable.js.@material-ui/core/Button @ QuestionnaireListTable.js:20 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../src/component/QuestionnaireList.js.react @ QuestionnaireList.js:3 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../src/App.js.react @ App.js:11 newRequire @ src.61e5e814.js:48 localRequire @ src.61e5e814.js:54 parcelRequire.../src/index.js.react @ index.js:4 newRequire @ src.61e5e814.js:48 parcelRequire.../node_modules/object-assign/index.js @ src.61e5e814.js:80 (anonymous) @ src.61e5e814.js:106

securedeveloper commented 6 years ago

@adityafuture01 we are using an alias library for xlsx to support styling in excel. The library we are using is https://www.npmjs.com/package/xlsx-style please try to install that package as well. I hope it will work with that library.

adityafuture01 commented 6 years ago

@securedeveloper, I did install the xlsx-style. The issue is still the same.

Uncaught Error: Cannot find module 'jszip' at newRequire (src.61e5e814.js:39) at localRequire (src.61e5e814.js:54) at make_xlsx (xlsx.js:1344) at Object.parcelRequire.../node_modules/react-data-export/node_modules/xlsx/xlsx.js../dist/cpexcel (xlsx.js:6) at newRequire (src.61e5e814.js:48) at localRequire (src.61e5e814.js:54) at Object.parcelRequire.../node_modules/react-data-export/dist/ExcelPlugin/components/ExcelFile.js.react (ExcelFile.js:19) at newRequire (src.61e5e814.js:48) at localRequire (src.61e5e814.js:54) at Object.parcelRequire.../node_modules/react-data-export/dist/index.js../ExcelPlugin/components/ExcelFile (index.js:7)

securedeveloper commented 6 years ago

@adityafuture01 give me some time and I will get back to you after testing this project with Parcel bundler

adityafuture01 commented 6 years ago

Thank you @securedeveloper

harry-sm commented 6 years ago

@securedeveloper I am having the same issue with jszip.

securedeveloper commented 6 years ago

@harry-sm are you using webpack configuration or you have another setup system?

harry-sm commented 6 years ago

@securedeveloper I am using parcel@1.9.7

securedeveloper commented 6 years ago

Actually I already tested and investigated the above issue a bit, my suggestion will be adding jszip, and file-saver library by CDN or npm.

harry-sm commented 6 years ago

@securedeveloper I'll try that and let you know

harry-sm commented 6 years ago

@securedeveloper Still not working I have installed file-saver and jzip but still nothing.

C:\Users............\node_modules\xlsx\xlsx.js:1205:30: Cannot statically evaluate fs argument 1203 | function readFileSync(filename, options) { 1204 | if(fs === undefined) fs = require('fs');

1205 | return parse(fs.readFileSync(filename), options); | ^ 1206 | } 1207 | image