Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deno install doesn't work with local deno.json[c] imports #22961

Closed
NfNitLoop opened this issue Mar 17, 2024 · 2 comments
Closed

deno install doesn't work with local deno.json[c] imports #22961

NfNitLoop opened this issue Mar 17, 2024 · 2 comments
Labels
duplicate a duplicate of another issue

Comments

@NfNitLoop
Copy link

NfNitLoop commented Mar 17, 2024

Problem

When I specify imports in my deno.jsonc, if I try to deno install my_main.ts, it succeeds.

However, running that script gives an error, because the import map was not respected during install:

error: Relative import path "@nostr/tools" not prefixed with / or ./ or ../
    at file:///C:/Users/codyc/code/nostr/nt.ts:10:63

(Tested with Deno v1.41.3)

Context

Before JSR, I stuck with the deps.ts (or deps/*.ts) pattern for modules, so that they could be used as libraries or executable scripts, locally or remotely. During development, I could just deno install --permissions my_main.ts and then my_main sub command ... to iteratively test.

But my understanding is that that will be incompatible with jsr.io packages, since we can't use http(s) imports there. But when switching to using an import map, deno install has had a regression for the above use case.

I mentioned this in Discord and was asked to create an issue. :)

Workarounds

I see that deno install has an --import-map option. But that option doesn't know how to parse a deno.jsonc file. I don't see an option to use imports from that file.

I could automate extracting that import map for local use. Or manually maintain both. But that seems like it should be unnecessary.

As a workaround, I'm just using a deno task entry to call deno run --deno-args my_main.ts

@NfNitLoop
Copy link
Author

But my understanding is that that will be incompatible with jsr.io

I just realized there's a compatible workaround:

I could use the deps.ts pattern, and just move my jsr: imports there.

Feels odd to need to do this when jsr.io supports deno.jsonc, though. deno install should too!

@dsherret
Copy link
Member

Duplicate of #17834 and a few other issues. See #17855

@dsherret dsherret closed this as not planned Won't fix, can't repro, duplicate, stale Mar 17, 2024
@dsherret dsherret added the duplicate a duplicate of another issue label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate a duplicate of another issue
Projects
None yet
Development

No branches or pull requests

2 participants