Simplest way to download and unzip files in Node.js cross-platform?

前端 未结 11 1541
一个人的身影
一个人的身影 2020-11-30 23:44

Just looking for a simple solution to downloading and unzipping .zip or .tar.gz files in Node.js on any operating system.

Not sure if this

11条回答
  •  Happy的楠姐
    2020-12-01 00:12

    Download and extract for .tar.gz:

    const https = require("https");
    const tar = require("tar");
    
    https.get("https://url.to/your.tar.gz", function(response) {
      response.pipe(
        tar.x({
          strip: 1,
          C: "some-dir"
        })
      );
    });
    

提交回复
热议问题