I have the TypeScript below in a file called download.ts. It runs using deno run --allow-all download.ts but fails on deno compile --allow-all download.ts
Is there something about the way imports are handled in Deno that is causing the issue? or some other code structure I need to write differently? I have gotten "hello world" examples to compile on my machine.
import { readerFromStreamReader, copy } from "https://deno.land/std/streams/conversion.ts";
async function download(url: string, path: string) {
const rsp = await fetch(url);
console.log(url);
console.log(path);
const rdr = rsp.body?.getReader();
if (rdr) {
const r = readerFromStreamReader(rdr);
const f = await Deno.open(path, { create: true, write: true });
// copy from reader to file
await copy(r, f);
f.close();
}
}
const url = "https://qwerty224.s3.amazonaws.com/sample.zip";
const path = "C:/temp/sample.zip";
download(url, path);
There error I get during compile is:
Platform: windows x86_64 Version: 1.25.0 Args: ["C:\Users\mjlef\.deno\bin\deno.exe", "compile", "--allow-all", "download.ts"]
thread 'main' panicked at 'called Option::unwrap() on a None value', C:\Users\runneradmin.cargo\registry\src\github.com-1ecc6299db9ec823\eszip-0.25.0\src\v2.rs:512:60
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
UPDATE: If I change the import to
import { readerFromStreamReader, copy }
from "https://deno.land/[email protected]/streams/conversion.ts";
It works. Any more current version and it fails. What is the long term solution?