fresh: Relative import path "preact" not prefixed with / or ./ or ../deno(import-prefix-missing)

Hello! I literally just started a new project to learn Fresh and I got these issues, I wonder if anyone has any idea of what might be happening?

$ deno -V: deno 1.23.4 Installed via: curl -fsSL https://deno.land/install.sh | sh

macOS: Monterrey

settings.json

{
  "deno.enable": true,
  "deno.unstable": true
}

import_map.json

{
  "imports": {
    "$fresh/": "https://deno.land/x/fresh@1.0.1/",
    "preact": "https://esm.sh/preact@10.8.2",
    "preact/": "https://esm.sh/preact@10.8.2/",
    "preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?deps=preact@10.8.2"
  }
}

Using VsCode and https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno

image

image image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 22 (2 by maintainers)

Most upvoted comments

Ah, ok… hmmm… well, that would explain it all. 😄

  • Auto-detection of a config file doesn’t work in multi-root workspaces. This is a bug and I will raise an issue about it.
  • Setting the option in settings.json in a multi-root workspace doesn’t work in vscode because that tries to set it for the workspace folder, but we don’t allow that setting there, it needs to be set at the overall workspace level (which is what the IDE ensures works). This isn’t really a bug, though I can understand it is confusing, but if the auto-detection worked, we wouldn’t have been here!

Closing because multi-root workspace support is an upstream Deno issue, and not specific to Fresh.

I’m having this same issue on newly created Fresh project using deno run -A -r https://fresh.deno.dev my-project.

image

I’m having this same issue on newly created Fresh project using deno run -A -r https://fresh.deno.dev my-project.

image

// On VSCode just add to your ~/.config/Code/User/settings.json:

"deno.enablePaths": [
   "./worker",
]

Ok, for some reason the Deno Language Server is not identifying the configuration and import map. In the logged output I would expected to see something like:

Starting Deno language server...
  version: 1.23.4 (release, x86_64-apple-darwin)
  executable: /Users/xxx/.deno/bin/deno
Connected to "Visual Studio Code" 1.69.2
  Auto-resolved configuration file: "file:///Users/xxx/deno.json"
Setting import map from configuration file: "./import-map.json"
  Resolved import map: "/Users/xxx/import-map.json"

For troubleshooting purposes, could you try to things and see if the output changes:

  • renaming the deno.json to deno.jsonc and reloading (Developer: Reload Window from the command palette)
  • adding "deno.config" option to your workspace settings pointing to the config file and reloading