Search code examples
javascriptnode.jsangularbufferzlib

Error: ./node_modules/zlib/lib/zlib.js './zlib_bindings'


i finished upgrading to angular 11 and i have error in zlib library. I need this to convert a Ibuffer. When i uploading the project I get this error:

Error: ./node_modules/zlib/lib/zlib.js Module not found: Error: Can't resolve './zlib_bindings' in '..\node_modules\zlib\lib'

The code:

const zlib = require('zlib');
const buffer = Buffer.from(data,'base64');
zlib.inflateSync(buffer, (err,buffer) => {
    if (err) {
        console.error('An error occurred:', err);
    }
    
    this.excelService.export("xxx" + `${base.name}`, buffer.toString());
});

Solution

  • I had similar problem but when trying to add firebase Admin SDK and thanks to some guy on github i just make a copy and then renamed the copy zlib/lib/zlib - Copy.js to zlib/lib/zlib_bindings.js and then it started working.

    Link to github issue: https://github.com/diegomura/react-pdf/issues/1678