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

Import maps (from deno.json > "imports") don't work in VS Code #25631

Closed
cristian-spiescu opened this issue Sep 14, 2024 · 7 comments
Closed

Comments

@cristian-spiescu
Copy link

Version: Deno 1.41.2

It's only after the standard lib moved to JSR that I found out about the deno add command, and the "import maps" feature. Leveraging this, deno.json > imports is somehow the equivalent of package.json > dependencies.

Before this, I was thinking that the pattern of deps.ts is the equivalent of package.json > dependencies.

However, I observe that in my case, VS Code doesn't recognize deno.json > imports. I.e., I have this:

image

But the IDE complains about this:

image

The program executes successfully. So Deno itself did recognize the import.

I tried various combination of settings.json:

image

I also inspected Output > Deno Language Server, but nothing seemed suspect.

Searching the Internet didn't gave much results. #20210 seems a bit related, but the context there (i.e. a deno.json being in a subdir of the project) is not similar to mine.

@dsherret
Copy link
Member

1.41.2

Is it fixed in the latest Deno version?

@maxxmberry
Copy link

Deno Version: 1.46.3

I'm getting another error but also possibly because of JSR. I'm trying to import parseArgs from the @std/cli package to my file, but I'm getting an error for an uncached or missing remote URL.

I added @std/cli into the import map like usual, but when I write import { parseArgs } from "@std/cli";, the error appears.
deno-issue-screenshot

I don't know if this issue is related to yours, but I thought I'd reach out.

@BlackAsLight
Copy link

I'm trying to import parseArgs from the @std/cli package to my file, but I'm getting an error for an uncached or missing remote URL.

Click the Quick Fix... button that appears in the image and click the cache dependency option. The error is saying that it doesn't have that dependency stored locally on the device so it is having trouble giving you information about it. Running the program once will also cache any missing dependencies, but I believe you can also do deno cache <file> and it will cache any missing dependencies imported in said file.

@maxxmberry
Copy link

Running the program once will also cache any missing dependencies

Thank you for the help. I'm somewhat new to TS/Deno and coding in VS Code, so I didn't know running the program would help the issue. Thanks again!

@lucacasonato lucacasonato closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
@cristian-spiescu
Copy link
Author

You have closed the issue. Unfortunately I still have the problem.
Some hints would be appreciated. Thanks.

@kt3k
Copy link
Member

kt3k commented Sep 17, 2024

@cristian-spiescu What happens if you upgrade Deno to the latest (1.46.3)?

@lucacasonato
Copy link
Member

@cristian-spiescu is the .vscode folder in the root directory of your vscode project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants