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.json not recognized if not at root of workspace #938

Closed
mfulton26 opened this issue Sep 25, 2023 · 1 comment · Fixed by denoland/deno#24206
Closed

deno.json not recognized if not at root of workspace #938

mfulton26 opened this issue Sep 25, 2023 · 1 comment · Fixed by denoland/deno#24206
Assignees

Comments

@mfulton26
Copy link

Describe the bug

If I define my deno.json file at the root my workspace then I get proper Deno language support but if I put it in a folder then I do not.

To Reproduce

  1. Run "Deno: Initialize Workspace Configuration"
  2. Create a folder named "foo"
  3. Create a deno.json file in "foo" with some "imports" defined (e.g. for std lib)
  4. Create a main.ts file in "foo" and import something leveraging the "imports" defined in the deno.json file

Note how you'll get an error message from VSCode:

Relative import path "$std/flags/mod.ts" not prefixed with / or ./ or ../deno(import-prefix-missing)

However running deno run foo/main.ts works fine (and creates a deno.lock file too)

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..01cede9
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,5 @@
+{
+    "deno.enable": true,
+    "deno.lint": true,
+    "deno.unstable": false
+}
\ No newline at end of file
diff --git a/foo/deno.json b/foo/deno.json
new file mode 100644
index 0000000..55ca111
--- /dev/null
+++ b/foo/deno.json
@@ -0,0 +1,5 @@
+{
+  "imports": {
+    "$std/": "https://deno.land/std@0.202.0/"
+  }
+}
diff --git a/foo/main.ts b/foo/main.ts
new file mode 100644
index 0000000..57ebaf7
--- /dev/null
+++ b/foo/main.ts
@@ -0,0 +1,3 @@
+import { parse } from "$std/flags/mod.ts";
+
+console.log(parse(Deno.args));

Expected behavior

The VSCode Deno extension should provide code completion inside the subfolder just as it would if deno.json were at the root of the workspace instead.

Screenshots

image

Versions

vscode: 1.82.2 deno: 1.37.0 extension: 3.23.1

@nayeemrmn
Copy link
Collaborator

This will be coupled with #787. If you have only one subdirectory with a deno.json, you can work around this in the meantime by specifying "deno.config": "foo/deno.json" in your workspace settings.

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

Successfully merging a pull request may close this issue.

2 participants