Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

385
Views
¿Cómo extraigo un archivo tar en nodejs usando el método pipeline()?

Mi código actual se ve así:

 const gzip2 = zlib.createUnzip(); const pack2 = new tar.Unpack(); const source2 = Readable.from('public/img.tar.gz'); const destination2 = fs.createWriteStream('public/images2'); pipeline(source2, gzip2, pack2, destination2, (err) => { if (err) { console.error('An error occurred:', err); process.exitCode = 1; } });

Pero estoy recibiendo este error:

 internal/streams/pipeline.js:108 throw new ERR_INVALID_ARG_TYPE( ^ TypeError [ERR_INVALID_ARG_TYPE]: The "val" argument must be an instance of Readable, Iterable, or AsyncIterable. Received an instance of Unpack at makeAsyncIterable (internal/streams/pipeline.js:108:9) at pipeline (internal/streams/pipeline.js:265:15) at Object.<anonymous> (/mnt/c/index.js:39:1) at Module._compile (internal/modules/cjs/loader.js:1068:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10) at Module.load (internal/modules/cjs/loader.js:933:32) at Function.Module._load (internal/modules/cjs/loader.js:774:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) at internal/main/run_main_module.js:17:47 { code: 'ERR_INVALID_ARG_TYPE' }

yo también he intentado

 const pack2 = tar.extract();

sin suerte Si alguien puede ayudarme a extraer este archivo tar usando la canalización, para que también pueda descomprimir el archivo. Estaría muy agradecido. He visto a personas usar .pipe(tar.extract()) en línea, pero trato de mantener mi código lo más limpio y uniforme posible. Lamentablemente, esto: https://www.npmjs.com/package/tar no ha sido muy útil.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

const tar = require('tar.gz2') var read = tar().createReadStream('/public/images'); var write = fs.createWriteStream('compressed.tar.gz'); pipeline(read,write, (err) => { if (err) { throw err } })
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!