Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

npm compressing module to compress two subfolders

I need a .tgz with the following folder structure:
./folder1/folder2/ "multiples files here".

The first folder will never contain files but is necessary.

I want to use the "compressing" npm module ( https://www.npmjs.com/package/compressing ).
But when I use it like in the following code, only folder2 is included. When I create another folder before folder 1 its the same, only folder2 is in there.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const compressing = require('compressing');

try{
    compressing.tgz.compressDir('/folder1/folder2', 'destination.tgz')
}catch(e){
    console.log(e)
}

I also tried to only specifiy the path to folder1 in the compressDir function, but then I get an error "TarStreamError: ENOENT: no such file or directory".

How can I achieve this?

>Solution :

You’re getting the error because your path is incorrect. you are giving the function the path /folder1, meaning it tries to find the folder in the ROOT directory because of the initial /. instead use ./folder1 or just folder.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading