ngx-excel-export icon indicating copy to clipboard operation
ngx-excel-export copied to clipboard

Can't resolve 'fs' in xlsx-style

Open vixper opened this issue 6 years ago • 13 comments

Hi, I'm using angular 6 and I can export json data with XLSX using ngx-excel-export.

When I try to style the exported excel document through xlsx-style, I get building errors:

`WARNING in ./node_modules/xlsx-style/xlsx.js Module not found: Error: Can't resolve 'crypto' in 'D:\Web\node_modules\xlsx-style'

ERROR in ./node_modules/xlsx-style/xlsx.js Module not found: Error: Can't resolve 'fs' in 'D:\Web\node_modules\xlsx-style' ERROR in ./node_modules/xlsx-style/ods.js Module not found: Error: Can't resolve 'fs' in 'D:\Web\node_modules\xlsx-style'`

How can I solve that?

Thanks PS: I'm not using node or webpack, it's a simple angular application.

vixper avatar Jul 02 '18 09:07 vixper

same issue

kunj1234 avatar Aug 20 '18 06:08 kunj1234

any solution?

vixper avatar Aug 24 '18 07:08 vixper

Facing same issue in Angular 6 project. Any solution for this?

ShubhamJainSJ avatar Aug 31 '18 05:08 ShubhamJainSJ

same issue. Any solution for this? @vixper @ShubhamJainSJ

aminghe avatar Sep 30 '18 12:09 aminghe

Same issue, any solution???

ShivaInnovation avatar Oct 10 '18 03:10 ShivaInnovation

@ShivaInnovation

Hi, I've solved my problem with another library. I used exceljs.

https://github.com/guyonroche/exceljs#styles

Your code sample is this source https://www.ngdevelop.tech/export-to-excel-in-angular-6/

good luck

aminghe avatar Oct 10 '18 10:10 aminghe

Facing the same issue with Angular 6, any solution ?

abhinavkumar985 avatar Oct 17 '18 20:10 abhinavkumar985

Any solutions found? (aside from switching to a different module)

sw-tracker avatar Dec 25 '18 20:12 sw-tracker

same issue with Angular 7, any solution ?

ChloeQiuFeelGood avatar Feb 13 '19 04:02 ChloeQiuFeelGood

@vixper

`WARNING in ./node_modules/xlsx-style/xlsx.js Module not found: Error: Can't resolve 'crypto' in 'D:\Web\node_modules\xlsx-style'

to solve this issue , i modified source code of 'xlsx-style/dist/cpexcel.js' from var cpt = require('./cpt' + 'able'); to var cpt = cptable

ERROR in ./node_modules/xlsx-style/xlsx.js Module not found: Error: Can't resolve 'fs' in 'D:\Web\node_modules\xlsx-style' ERROR in ./node_modules/xlsx-style/ods.js Module not found: Error: Can't resolve 'fs' in 'D:\Web\node_modules\xlsx-style'`

for these two issues , i solved by adding node attribute to 'webpack.config.js',like this

node: {
  fs: "empty"
}

One passible reason here is the webpack treat 'fs' as package module but not node module

AngelLover2017 avatar Aug 01 '19 10:08 AngelLover2017

in my project webpack.config.js doesnt exist. how can i fix it ?

leventkalay avatar Nov 25 '21 12:11 leventkalay

在我的项目中 webpack.config.js 不存在。我该如何解决?

这里说的是自己项目的webpack.confog.js,而不是xlsx-style的,你可以自己在项目根目录新建一个webpack.config.js,让你在打包的时候自动正确识别fs。

Turing2048 avatar Jan 26 '22 04:01 Turing2048

in my project webpack.config.js doesnt exist. how can i fix it ?

Did you find any solutions?

sebastiananea avatar Oct 28 '23 19:10 sebastiananea