Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process version undefined #529

Open
katalinszenas opened this issue Aug 12, 2024 · 3 comments
Open

Process version undefined #529

katalinszenas opened this issue Aug 12, 2024 · 3 comments

Comments

@katalinszenas
Copy link

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
Copy link

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
Copy link

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

adm-zip: 0.5.16
cypress: 13.14.1

@craiganderson-iotv
Copy link

Unfortunately I've also encountered this issue, and have to use the following patch as a workaround:

adm-zip+0.5.16.patch:

diff --git a/node_modules/adm-zip/methods/inflater.js b/node_modules/adm-zip/methods/inflater.js
index 8769e66..a990c52 100644
--- a/node_modules/adm-zip/methods/inflater.js
+++ b/node_modules/adm-zip/methods/inflater.js
@@ -1,4 +1,4 @@
-const version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
+const version = +(process.versions ? process.versions.node ??  "" : "").split(".")[0] || 0;
 
 module.exports = function (/*Buffer*/ inbuf, /*number*/ expectedLength) {
     var zlib = require("zlib");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants