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.

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?


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.