Having a TypeScript file named download.ts, I successfully run it using deno run --allow-all download.ts but encounter failure with deno compile --allow-all download.ts
Could there be an issue related to how Deno handles imports that is causing this error? Is there a specific code structure adjustment I need to make? I have managed to compile "hello world" examples on my system.
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);
The error message I receive during compilation reads:
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: Switching the import statement to
import { readerFromStreamReader, copy }
from "https://deno.land/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e0939484a0d0ced1d4d9ced0">[email protected]</a>/streams/conversion.ts";
resolves the issue. However, any newer version causes a failure. What is the permanent solution?