TheTechsTech / node-7z-archive

ESM front-end to 7-Zip, featuring alternative 7z CLI tool, binaries for Linux, Windows, Mac OSX, and seamlessly create 7zip SFX self extracting archives targeting different platforms.
MIT License
13 stars 7 forks source link

binaries folder not created in node_modules/node-7z-archive #31

Open edo-z80-ise opened 1 year ago

edo-z80-ise commented 1 year ago

I've recently noticed this strange behavior: installing the package (npm install -S node-7z-archive) and trying to compress or extract something, I get the error: Error: spawn <... my path ... bla bla bla ...>\node_modules\node-7z-archive\binaries\win32\7za.exe ENOENT I've tried to understand why this happens, and knowing that this module is a wrapper of node-7z-forall (deprecated) on which everything worked instead, I tried to look inside node_modules and noticed that the binaries folder is missing. Fixed (apparently) by copying the binaries folder from node_modules/node-7z-forall to node_modules/node-7z-archive ...then everything works fine.

I've tried the same thing on both WIN 10 and Linux (Amazon AWS LightSail VM, Amazon Linux 2 OS) and getting the same behavior.

TheTechsTech commented 1 year ago

I've tried to understand why this happens, and knowing that this module is a wrapper of node-7z-forall (deprecated) on which everything worked instead,

This is no wrapper of node-7z-forall, your setup is messed up.

You should just delete whatever version you currently using, the whole folder, then do: npm install node-7z-archive

Check the CI test run https://github.com/TheTechsTech/node-7z-archive/actions. You have an issue with your system.

edo-z80-ise commented 1 year ago

This is no wrapper of node-7z-forall

OK, sorry, probably I've read wrong in internet

your setup is messed up.

maybe, but i've tried with a fresh brand new npm init and then doing only npm install node-7z-archive and have same problem. anyway hope is only a local problem (mine) so i can check install messages if something goes wrong.

thank you for your response

martinericksonn commented 1 year ago

Same here, I am currently having the problem of missing binaries in /node_modules/node-7z-archive/binaries/linux The directory only contains the following two files: 7zConwin32.sfx and 7zwin32.sfx I have tried clearing the cache, reinstalling the package, and running npm install again, but I am still getting the error:

Error: spawn /home/.../node_modules/node-7z-archive/binaries/linux/7za ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:476:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn .../node_modules/node-7z-archive/binaries/linux/7za',
  path: '...node_modules/node-7z-archive/binaries/linux/7za',
 ...
TheTechsTech commented 1 year ago

I can confirm the issue under WSL. I created a new folder did npm install node-7z-archive, it prompt for my password and then progress some until I got the same error you have. But the solution was also pointed out, apt-get update.

This package needs node-unar and that needs some other host OS system software to extract 7z binary downloaded. That's the reason for the password prompt.

I deleted everything in the folder and did apt-get update and then npm install node-7z-archive again. Then another issue appears and this is only under Linux, macOS.

Error downloading file: Error downloading file: Fetch to https://7-zip.org/a/lzma1701.7z failed, with status text: Not Found

This package hasn't been updated to current 7z version and the lzma1701.7z file has been removed from https://7-zip.org. I will update and switch to lzma1604.7z for now, not sure of compatibility issues.

Republished with 1.1.7 with links actually updated.

martinericksonn commented 1 year ago

Great! It works now, thanks

barakatmustafa commented 3 months ago

Is this happening again ?

TheTechsTech commented 3 months ago

Depends, What is your system setup/config and versions?

At this time I'm not using Node.js like before, nor the other package this was created for, so updates and fixes would be slow by me.

bilwit commented 3 months ago

Depends, What is your system setup/config and versions?

At this time I'm not using Node.js like before, nor the other package this was created for, so updates and fixes would be slow by me.

Happening here as well.

node-7z-archive 1.1.7 node v20.14.0

in node_modules/node-7z-archive there is no binaries directory

error thrown is node_modules/node-7z-archive/binaries/linux/7za ENOENT

EDIT: upon removing and then installing again the binaries now show up and works as normal, strange that this also happened to multiple other deployments for me

npm remove node-7z-archive npm i node-7z-archive

TheTechsTech commented 3 months ago

The GitHub Actions CI is not testing against Node v20, deleting and reinstalling might just be the fix.

bilwit commented 3 months ago

I can't get the remove/install thing to reliably work (or work at all since my last post). In my other environments (also Linux), the node_modules/node-7z-archive directory looks like this after install

7z1604.exe
LICENSE
README.md
cli
darwin
installer.mjs
lib
linux
linux-p7zip.7z
macos-p7zip.7z
node_modules
other32
package.json

and in the working dev environment it looks likes this

binaries
cli
lib
node_modules
installer.mjs
LICENSE
package.json
README.md

is it extracting the wrong installation (windows instead of detecting linux)?

TheTechsTech commented 3 months ago

No, the 7zip files would be automatically deleted after extracting, the binary files has actually downloaded but not extracted. I haven't tested anything under Node v20, that too could be the issue.

Also an Linux install should prompt for password because the host needs unar to extract 7z files. You should just delete node_modules folder all together. Then run install again.

What is log messages displayed when you run npm i node-7z-archive? If any issues would have been displayed.

TheTechsTech commented 3 months ago

Note on Windows and MacOS installs, the unar binary is downloaded also, it's an zip file. All the other dependencies here is really just to download and extract files, they have other benefits but that's there main purpose.

KillahB33 commented 1 month ago

Coming here with the same issue, npm i gives me the following. I am on Node v20.

➜  web git:(main) ✗ npm i node-7z-archive

added 18 packages, and audited 385 packages in 6s

137 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

UPDATE: Oh curious that worked, I am not sure why.

bilwit commented 1 month ago

Coming here with the same issue, npm i gives me the following. I am on Node v20.

➜  web git:(main) ✗ npm i node-7z-archive

added 18 packages, and audited 385 packages in 6s

137 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

UPDATE: Oh curious that worked, I am not sure why.

I couldn't get it to reliably install correctly across deployments so I ended up just baking in the binaries folder into my repo and copying it over as needed. There is also no errors shown during the install when it happens.

TheTechsTech commented 1 month ago

The install process is different among Windows, macOS, and Linux. I haven't tested anything beyond Node v18.

There seems to be an issue with previous installs, so it's best to just manually delete node_module folder, and do install again, which seem to correct the issue.

KillahB33 commented 1 month ago

@bilwit yep same, I am trying to build my container now that my test envs working and having the same issue.

It looks like for some reason the dependencies aren't being installed, I think you need to manually add node-unar to package.json as that's what I did right before my test env worked. I am going to test now though and will update.

UPDATE: I'm done troubleshooting for now but this is where I am at.

I was using nextjs standalone output which I thought was the issue but now that I am copying my full build to my image I am still having issues. The only thing I haven't tried that I did do on my testing machine is npm i unar, so my guess is that will solve my issues but will have to report back later when I get a chance to test.

KillahB33 commented 1 month ago

Looks like I'll be taking the same approach that @bilwit did, Even with doing a full build and full install for my deployment I can't get the binaries to come over. Appreciate the suggestion @bilwit !!

TheTechsTech commented 1 month ago

I just checked my local Node version, it's Node v16, I'm not really using JS lately.

I will try getting around to updating to newer version to track down issue. I believe might be some version changes when installing around security.

node-unar is already in the package.json file here. Why it's not actually pulling in is strange, definitely needed for actual extraction process.

LetrixZ commented 4 days ago

For people having this problem with Bun, you need to trust the script using bun pm trust.