import fs from 'fs'; import fetch from "node-fetch"; async function downloadFile(url, savePath) { let res = await fetch(url) return new Promise((resolve, reject) => { const dest = fs.createWriteStream(savePath); res.body.pipe(dest); res.body.on("end", () => resolve(savePath)); dest.on("error", reject); }) }