deno icon indicating copy to clipboard operation
deno copied to clipboard

Strange error message if you typo a remote package URL in a single-file script

Open Benaiah opened this issue 1 year ago • 3 comments

Version: Deno 2.0.0

Detailed version info:

deno 2.0.0 (stable, release, aarch64-apple-darwin)
v8 12.9.202.13-rusty
typescript 5.6.2

Running deno index.ts with a clean cache (ran deno clean immediately before) in a directory containing only index.ts with the following contents:

import { DB } from "https://deno.land/x/[email protected]/mod.ts"

(note: the [email protected] instead of [email protected] is intentional; that's what triggers this strange and misleading error)

...results in the following error:

deno-experiments % deno -A index.ts
error: unrecognized subcommand

  tip: some similar subcommands exist: 'init', 'lint'

Benaiah avatar Oct 11 '24 22:10 Benaiah

try deno run xxx

tobylai-toby avatar Oct 12 '24 00:10 tobylai-toby

PS D:\yad\deno> .\target\debug\deno -A  .\main.ts
error: Module not found "https://deno.land/x/[email protected]/mod.ts".
    at file:///D:/yad/deno/main.ts:1:20
PS D:\yad\deno> .\target\debug\deno run -A  .\main.ts
error: Module not found "https://deno.land/x/[email protected]/mod.ts".
    at file:///D:/yad/deno/main.ts:1:20
PS D:\yad\deno> 

I think it works; it is not a bug.

yazan-abdalrahman avatar Oct 13 '24 06:10 yazan-abdalrahman

I can not reproduce it, but I believe you this bug exists. The cause is likely in how we handle deno main.ts compared to deno run main.ts. Relevant code that is likely broken is https://github.com/denoland/deno/blob/afb33b3c2597c9ec943f71218b236486fbc86e23/cli/main.rs#L219.

lucacasonato avatar Oct 21 '24 09:10 lucacasonato