cthackers / adm-zip

A Javascript implementation of zip for nodejs. Allows user to create or extract zip files both in memory or to/from disk
MIT License
2.04k stars 376 forks source link

Process version undefined #529

Open katalinszenas opened 2 months ago

katalinszenas commented 2 months ago

Hi, I use this package in a Cypress cy.task to simply unzip.

After the 0.5.10 version the following code has an issue:

Cannot read properties of undefined (reading 'split')

      at ./node_modules/adm-zip/methods/inflater.js (webpack:///./node_modules/adm-zip/methods/inflater.js:1:44)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
      at ./node_modules/adm-zip/methods/index.js (webpack:///./node_modules/adm-zip/methods/index.js:2:0)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
      at ./node_modules/adm-zip/zipEntry.js (webpack:///./node_modules/adm-zip/zipEntry.js:4:14)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
      at ./node_modules/adm-zip/adm-zip.js (webpack:///./node_modules/adm-zip/adm-zip.js:3:17)
      at __webpack_require__ (webpack:///webpack/bootstrap:19:0)
 Tracing it this code has the issue:
 const version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;     

The process.versions is empty somehow in my case, so the process.versions.node is undefined.

linasburneika commented 2 months ago

This is happening if process browser shim is used (https://github.com/defunctzombie/node-process). It defines process.versions as empty object, causing split function to fail.

mgentry612 commented 1 month ago

I'm also experiencing this issue while running with Cypress.

adm-zip: 0.5.16 cypress: 13.14.1