Deno.enable not working
https://docs.deno.com/runtime/manual/references/vscode_deno/#deno-enabling-a-workspace
In another project, I manually created (in VSC) the root folder
.vscode
and the file settings.json
with the content { "deno.enable": true }
and it worked.
In a new project (in the same workspace), I tried this again but it does not work in the editor:
Cannot find module 'jsr:@std/dotenv' or its corresponding type declarations.ts(2307)
When trying to run, it works fine.
I'm using Deno 1.42.4 and VSCodium 1.88.1.2410451 Replies
It seems like you're encountering an issue where the Deno extension in Visual Studio Code (VSCode) isn't recognizing a module, even though running the code with Deno CLI works fine. Here are a few steps you can take to troubleshoot this issue, based on the documentation:
1. Ensure Deno is Enabled for the Workspace: The documentation states that you need to enable Deno for the workspace to have support for Deno APIs and module resolution. You've already created a
.vscode/settings.json
with { "deno.enable": true }
, which is correct. However, make sure this setting is applied to the correct workspace folder if you're using a multi-root workspace.
2. Initialize Workspace Configuration: The documentation suggests using the "Deno: Initialize Workspace Configuration" command from the VSCode command palette. This sets up the necessary configuration and asks if you want to enable linting and unstable APIs.
3. Check for Workspace Folder Settings: If you're working with a multi-root workspace, you might need to enable Deno for specific workspace folders. The deno.enablePaths
setting allows you to specify which sub-paths should be Deno-enabled.
4. Restart VSCode: Sometimes, changes to the settings might not take effect until you restart your editor. Try closing and reopening VSCode to ensure the settings are reloaded.
5. Check for Conflicting Extensions: Ensure that there are no other extensions that might conflict with the Deno extension, especially those related to TypeScript or JavaScript language services.
6. Check Deno Language Server Status: You can use the "Deno: Language Server Status" command from the command palette to check what the Deno language server thinks is your current active configuration.
7. **Disable TypeScript ProjectDiagnostics**: Make sure that the VSCode configuration
enableProjectDiagnostics
is disabled, as it can cause TypeScript language server to show errors that Deno should handle.
If you've gone through these steps and the issue persists, it might be a bug with the Deno extension. In that case, consider searching for similar issues or reporting a new bug at the vscode_deno GitHub repository.
Remember to check the exact path you're using for the module import. If there's a typo or incorrect path, that could also cause the module resolution to fail in the editor. 🦕So I have to guess no one knows anything about this? Can't continue using Deno in this state
cc @nayeemrmn
i started getting this too. just upgraded from 1.42.1 to 1.42.4 and everything stopped working
lint & format settings ignored. cant find jsr (or any) packages
@lukeed do you have the same problem if you update to latest Canary? (
deno upgrade --canary
)before i upgrade, to be clear, the cli works correctly
its just the vscode aspect
Yeah, vs code calls into CLI
k 2s
still happens
my quick test is that saving file is formatting in a way that doesnt follow my deno.json fmt options
as soon as i do
deno.enablePaths = ["./deno.json"]
the fmt config is respected but everything else breaks
i hope https://github.com/denoland/vscode_deno/issues/1099#issuecomment-2028790434 is not here to stay, this is a breaking/awful changeAlright, we'll look into that today
This means ONLY
deno.json
is enabled. What enable-related settings did you have before?none. i allow/expect the entire project to be supported because of root deno.json existence
but its ignored unless explicitly inserted into that array (following your comment)
Okay, that was meant for people already using
enablePaths
. This is unexpected looking into it
Does it work with enable: true
?no
well
the file is completely ignored
so any import map entries & any lint/fmt settings are ignored
deno itself is still working, in that some linting/formatting is happening, but not as it should
im back on 1.42.1 & everyhting works as exepected
Do errors have like
ts(2307)
like OP, or is it deno-ts(2307)
at the end?there are no errors, its working just not respecting my config
Lastly, if you open the output panel by clicking the Deno <version> button at the bottom, does it mention the
deno.json
anywhere underneath Refreshing configuration tree...
?lemme update again, 1s
Just copy output panel contents
yes, it finds all of them
altho 1.42.1 only finds the root
Yeah that's expected I think, does your file have some other empty
deno.json
closer to it?so whats probably happening is 1.42.4 is finding all & then looking for lint/fmt only in the first file? hwoever, it loops thru all w/ "applying import maps"
there are no empty files
@lukeed is that project open-source?
not yet, here are the outputs
Okay, and the fmt/lint config is not applied in any file? Or just certain files?
What's the relative path of the file you're interested in? What should happen is import map uses the root deno.json only, lint and fmt settings respect the most local deno.json
import maps do appear to be working; mis remembered sorry.
this is now rly w/ linting & formatting rules
not applied to any files in 1.42.4
Okay, you have to copy all your linting and formatting rules to all deno.json's. We don't apply inheritance yet, can fix this soon. It worked in previous versions because the more local deno.json's weren't respected at all
i also have no root
.ts
files, so if im following your theory, what may be happening in 1.42.4 is that A/foo.ts
is loading A/deno.json
only & since it finds no lint/fmt rules there, it uses Deno defaults instead of continuing to the root deno.json
config (as it did before)
you did/were before. it works great in 1.42.1Yeah, before
A/deno.json
wasn't read at all by the LSPoh i just read rest of message 🙈 sorry
FYI @lukeed we will be releasing v1.43.0 tomorrow morning, we will try to fix it by then, but if we can't it will be fixed in the next patch release
ok, thanks both
i guess my final feedback here is that 1) im rly loving deno; but 2) in trying to chase this down since last night, ive realized that an area where Deno could/should improve is maintaining an actual changelog
That's great to hear. We'll work on some solutions to provide better changelog for patch releases
eg, theres only 1 mention of
workspace
on this page https://github.com/denoland/deno/releases & ~2 hours spent diving thru issues, comments, blog & docs only yielded https://github.com/denoland/vscode_deno/issues/1099#issuecomment-2028790434 as closest resultGot it, workspaces are still very much experimental and poorly documented, but will improve the docs on them
GitHub
suggestion: document workspaces functionality · Issue #415 · denola...
This is important as the Deno Standard Library will become a workspaces-enabled codebase once it is fully ported to JSR. Documenting how workspaces work will be important to those maintaining and c...
happy to give addl feedack as you continue working thru them
all my deno projects are monorepos / "workspaces"
Yes! That would be very useful, just to be clear are you using
workspaces
setting in deno.json
?which is why this latest upgrade blew up on me 😅
nope, didnt know it existed haha. again, it was jsut a structure i imported/started doing & it happened to work
Got it, alright, I'll make sure we address the workspaces docs
( it's also not in the json schema for deno.json definition, so vscode isnt suggesting the key )
We'll add it right away
Thanks for looking into this! Feel free to ping me when a new version is live with a fix.
Ah, maybe this will also fix VSC ignoring the import map? Same thing basically, the editor can't resolve imports from the import map. But when running the file, it works as it's supposed to.
It should be available in canary version in ~1h
@lukeed @MOtherMetroid this fix is now available on canary if you wanna try it
Gonna try tomorrow, it's past midnight for me. :fast_deno:
seems to be working great, thanks @nayeemrmn @bartlomieju! (even without workspace config anywhere)
Huh, it didn't fix it for me. But just now, when I created a
deno.json
file, the error was gone... even though the file is completely empty. Is this expected behaviour?
Edit: Turns out deno.enable
isn't even needed? I'm confused @.@
Import maps are still not resolved in the editor 😦
deno.json
main.ts
Relative import path "dotenv" not prefixed with / or ./ or ../deno(import-prefix-missing)
This should be how it's supposed to work though, right?ya, by default (i think still) you dont need it if there's a deno.json file in your project root
make sure you restart vscode or reload workspace after doing the canary upgrade
otherwise the old lsp will still be running
@MOtherMetroid if it still doesn't work, could you please open an issue in https://github.com/denoland/deno/issues with as much info as possible about your setup?
GitHub
Issues · denoland/deno
A modern runtime for JavaScript and TypeScript. Contribute to denoland/deno development by creating an account on GitHub.